Skip to content

Commit ad7c547

Browse files
committed
Squashed commit of the following:
commit 6cf6f9c Author: James Ives <[email protected]> Date: Sun Sep 29 11:41:55 2024 -0400 fix: update tracking commit 9bb8292 Author: James Ives <[email protected]> Date: Sun Sep 29 11:38:22 2024 -0400 Update worktree.ts commit 6d0725e Author: James Ives <[email protected]> Date: Sun Sep 29 11:36:04 2024 -0400 Update worktree.ts commit f24119c Author: James Ives <[email protected]> Date: Sun Sep 29 11:32:45 2024 -0400 Update worktree.ts commit a93ccc9 Author: James Ives <[email protected]> Date: Sun Sep 29 11:30:49 2024 -0400 Update worktree.ts commit 422f948 Author: James Ives <[email protected]> Date: Sun Sep 29 11:28:54 2024 -0400 Update worktree.ts commit 84c87e3 Author: James Ives <[email protected]> Date: Sun Sep 29 11:23:48 2024 -0400 Update worktree.ts commit 3b0b9cb Author: James Ives <[email protected]> Date: Sun Sep 29 11:16:43 2024 -0400 Update build.yml commit f1cf93b Author: James Ives <[email protected]> Date: Sun Sep 29 11:11:58 2024 -0400 Update worktree.ts
1 parent ff20230 commit ad7c547

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ jobs:
113113
- name: Tweak content to publish to existing branch
114114
if: ${{ matrix.branch == 'gh-pages' }}
115115
run: |
116-
RANDOM_CHAR=$(echo $RANDOM | tr -dc 'a-zA-Z0-9' | fold -w 1 | head -n 1)
117-
echo "<!-- just sayin $RANDOM_CHAR -->" >> integration/index.html
116+
echo "<!-- just sayin -->" >> integration/index.html
118117
119118
- name: Deploy with modifications to existing branch
120119
id: modified

__tests__/git.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ describe('git', () => {
239239
await deploy(action)
240240

241241
// Includes the call to generateWorktree
242-
expect(execute).toHaveBeenCalledTimes(13)
242+
expect(execute).toHaveBeenCalledTimes(14)
243243
expect(rmRF).toHaveBeenCalledTimes(1)
244244
})
245245

src/worktree.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,26 @@ export async function generateWorktree(
100100
info(
101101
'Error encountered while checking out branch. Attempting to continue with a new branch name.'
102102
)
103+
103104
branchName = `temp-${Date.now()}`
104-
checkout = new GitCheckout(branchName)
105105

106-
await execute(
107-
checkout.toString(),
108-
`${action.workspace}/${worktreedir}`,
109-
action.silent
110-
)
106+
try {
107+
checkout = new GitCheckout(branchName, `origin/${action.branch}`)
108+
await execute(
109+
checkout.toString(),
110+
`${action.workspace}/${worktreedir}`,
111+
action.silent
112+
)
113+
} catch (error) {
114+
info('Unable to track the origin branch…')
115+
116+
checkout = new GitCheckout(branchName)
117+
await execute(
118+
checkout.toString(),
119+
`${action.workspace}/${worktreedir}`,
120+
action.silent
121+
)
122+
}
111123
}
112124

113125
if (!branchExists) {
@@ -128,19 +140,19 @@ export async function generateWorktree(
128140
action.silent
129141
)
130142
}
143+
}
131144

132-
/**
133-
* Ensure that the workspace is a safe directory.
134-
*/
135-
try {
136-
await execute(
137-
`git config --global --add safe.directory "${action.workspace}/${worktreedir}"`,
138-
action.workspace,
139-
action.silent
140-
)
141-
} catch {
142-
info('Unable to set worktree temp directory as a safe directory…')
143-
}
145+
/**
146+
* Ensure that the workspace is a safe directory.
147+
*/
148+
try {
149+
await execute(
150+
`git config --global --add safe.directory "${action.workspace}/${worktreedir}"`,
151+
action.workspace,
152+
action.silent
153+
)
154+
} catch {
155+
info('Unable to set worktree temp directory as a safe directory…')
144156
}
145157
} catch (error) {
146158
throw new Error(

0 commit comments

Comments
 (0)