ci: checkout existing branch on snapshots

This commit is contained in:
Hans Larsen 2019-01-23 11:54:59 -08:00 committed by Hans
parent bf228a064c
commit b360206b31

View File

@ -91,7 +91,12 @@ async function _publishSnapshot(
_exec('git', ['clone', url], { cwd: root }, publishLogger); _exec('git', ['clone', url], { cwd: root }, publishLogger);
if (branch) { if (branch) {
_exec('git', ['checkout', '-B', branch], { cwd: destPath }, publishLogger); // Try to checkout an existing branch, otherwise create it.
try {
_exec('git', ['checkout', branch], { cwd: destPath }, publishLogger);
} catch {
_exec('git', ['checkout', '-b', branch], { cwd: destPath }, publishLogger);
}
} }
// Clear snapshot directory before publishing to remove deleted build files. // Clear snapshot directory before publishing to remove deleted build files.