Skip to content

Commit

Permalink
Merge branch 'dev' into releases/v4
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Sep 29, 2024
2 parents 0c6bce4 + ad7c547 commit 77b5e66
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ jobs:
- name: Tweak content to publish to existing branch
if: ${{ matrix.branch == 'gh-pages' }}
run: |
RANDOM_CHAR=$(echo $RANDOM | tr -dc 'a-zA-Z0-9' | fold -w 1 | head -n 1)
echo "<!-- just sayin $RANDOM_CHAR -->" >> integration/index.html
echo "<!-- just sayin -->" >> integration/index.html
- name: Deploy with modifications to existing branch
id: modified
Expand Down
2 changes: 1 addition & 1 deletion __tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ describe('git', () => {
await deploy(action)

// Includes the call to generateWorktree
expect(execute).toHaveBeenCalledTimes(13)
expect(execute).toHaveBeenCalledTimes(14)
expect(rmRF).toHaveBeenCalledTimes(1)
})

Expand Down
48 changes: 30 additions & 18 deletions src/worktree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,26 @@ export async function generateWorktree(
info(
'Error encountered while checking out branch. Attempting to continue with a new branch name.'
)

branchName = `temp-${Date.now()}`
checkout = new GitCheckout(branchName)

await execute(
checkout.toString(),
`${action.workspace}/${worktreedir}`,
action.silent
)
try {
checkout = new GitCheckout(branchName, `origin/${action.branch}`)
await execute(
checkout.toString(),
`${action.workspace}/${worktreedir}`,
action.silent
)
} catch (error) {
info('Unable to track the origin branch…')

checkout = new GitCheckout(branchName)
await execute(
checkout.toString(),
`${action.workspace}/${worktreedir}`,
action.silent
)
}
}

if (!branchExists) {
Expand All @@ -128,19 +140,19 @@ export async function generateWorktree(
action.silent
)
}
}

/**
* Ensure that the workspace is a safe directory.
*/
try {
await execute(
`git config --global --add safe.directory "${action.workspace}/${worktreedir}"`,
action.workspace,
action.silent
)
} catch {
info('Unable to set worktree temp directory as a safe directory…')
}
/**
* Ensure that the workspace is a safe directory.
*/
try {
await execute(
`git config --global --add safe.directory "${action.workspace}/${worktreedir}"`,
action.workspace,
action.silent
)
} catch {
info('Unable to set worktree temp directory as a safe directory…')
}
} catch (error) {
throw new Error(
Expand Down

0 comments on commit 77b5e66

Please # to comment.