From bcbcb16b6a2ea0a825f31bfbc88fb737dc188c34 Mon Sep 17 00:00:00 2001 From: Steve Rowe Date: Wed, 20 Jun 2018 09:38:12 -0400 Subject: [PATCH] Make sure remote branch is available and tracked locally, and merge remote into local branch --- dev-tools/scripts/reproduceJenkinsFailures.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dev-tools/scripts/reproduceJenkinsFailures.py b/dev-tools/scripts/reproduceJenkinsFailures.py index edfe2d4570e..aca2e104b7c 100644 --- a/dev-tools/scripts/reproduceJenkinsFailures.py +++ b/dev-tools/scripts/reproduceJenkinsFailures.py @@ -158,11 +158,18 @@ def prepareWorkspace(useGit, gitRef): checkoutCmd = 'git checkout %s' % gitRef code = run(checkoutCmd) if 0 != code: + addWantedBranchCmd = "git remote set-branches --add origin %s" % gitRef checkoutBranchCmd = 'git checkout -t -b %s origin/%s' % (gitRef, gitRef) # Checkout remote branch as new local branch - print('"%s" failed. Trying "%s".' % (checkoutCmd, checkoutBranchCmd)) + print('"%s" failed. Trying "%s" and "%s".' % (checkoutCmd, addWantedBranchCmd, checkoutBranchCmd)) + code = run(addWantedBranchCmd) + if 0 != code: + raise RuntimeError('ERROR: "%s" failed. See above.' % addWantedBranchCmd) code = run(checkoutBranchCmd) if 0 != code: raise RuntimeError('ERROR: "%s" failed. See above.' % checkoutBranchCmd) + code = run('git merge') + if 0 != code: + raise RuntimeError('ERROR: "git merge" failed. See above.') gitCheckoutSucceeded = True run('git merge --ff-only', rememberFailure=False) # Ignore failure on non-branch ref