Skip to content

Commit 77b5e66

Browse files
committed
Merge branch 'dev' into releases/v4
2 parents 0c6bce4 + ad7c547 commit 77b5e66

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

.github/workflows/build.yml

+1-2
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

+1-1
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

+30-18
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)