Skip to content

Commit b360206

Browse files
committed
ci: checkout existing branch on snapshots
1 parent bf228a0 commit b360206

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/snapshots.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ async function _publishSnapshot(
9191

9292
_exec('git', ['clone', url], { cwd: root }, publishLogger);
9393
if (branch) {
94-
_exec('git', ['checkout', '-B', branch], { cwd: destPath }, publishLogger);
94+
// Try to checkout an existing branch, otherwise create it.
95+
try {
96+
_exec('git', ['checkout', branch], { cwd: destPath }, publishLogger);
97+
} catch {
98+
_exec('git', ['checkout', '-b', branch], { cwd: destPath }, publishLogger);
99+
}
95100
}
96101

97102
// Clear snapshot directory before publishing to remove deleted build files.

0 commit comments

Comments
 (0)