Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 6cf6f9c
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:41:55 2024 -0400

    fix: update tracking

commit 9bb8292
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:38:22 2024 -0400

    Update worktree.ts

commit 6d0725e
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:36:04 2024 -0400

    Update worktree.ts

commit f24119c
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:32:45 2024 -0400

    Update worktree.ts

commit a93ccc9
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:30:49 2024 -0400

    Update worktree.ts

commit 422f948
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:28:54 2024 -0400

    Update worktree.ts

commit 84c87e3
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:23:48 2024 -0400

    Update worktree.ts

commit 3b0b9cb
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:16:43 2024 -0400

    Update build.yml

commit f1cf93b
Author: James Ives <iam@jamesiv.es>
Date:   Sun Sep 29 11:11:58 2024 -0400

    Update worktree.ts
  • Loading branch information
JamesIves committed Sep 29, 2024
1 parent ff20230 commit ad7c547
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 ad7c547

Please sign in to comment.