summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean McAllister <smcallis@google.com>2020-05-18 09:15:51 -0600
committerSean McAllister <smcallis@google.com>2020-05-19 15:25:42 +0000
commit682f0b6426a06ed1e89b130d50c6521b1c67d529 (patch)
tree6d1bcc4dc2c754ce5fccb633d0145c5d11335dac
parente7082ccb54ad870b185e99d7e39d1959c65ff899 (diff)
downloadgit-repo-682f0b6426a06ed1e89b130d50c6521b1c67d529.tar.gz
Fix how we format the full destination branch when uploading.
If the dest-branch attribute is set in the project manifest, then we need to push to that branch. Previously, we would unconditionally pre-pend the refs/heads prefix to it. The dest-branch attribute is allowed to be a ref expression though, so it may already have it. Simple fix is to check if it already has the prefix before adding it. Bug: crbug.com/gerrit/12770 Change-Id: I45d6107ed6cf305cf223023b0ddad4278f7f4146 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/268152 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Sean McAllister <smcallis@google.com>
-rw-r--r--subcmds/upload.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py
index cf3c8a9f..3dd9fd25 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -23,6 +23,7 @@ from command import InteractiveCommand
23from editor import Editor 23from editor import Editor
24from error import HookError, UploadError 24from error import HookError, UploadError
25from git_command import GitCommand 25from git_command import GitCommand
26from git_refs import R_HEADS
26from project import RepoHook 27from project import RepoHook
27 28
28from pyversion import is_python3 29from pyversion import is_python3
@@ -462,7 +463,10 @@ Gerrit Code Review: https://www.gerritcodereview.com/
462 # Make sure our local branch is not setup to track a different remote branch 463 # Make sure our local branch is not setup to track a different remote branch
463 merge_branch = self._GetMergeBranch(branch.project) 464 merge_branch = self._GetMergeBranch(branch.project)
464 if destination: 465 if destination:
465 full_dest = 'refs/heads/%s' % destination 466 full_dest = destination
467 if not full_dest.startswith(R_HEADS):
468 full_dest = R_HEADS + full_dest
469
466 if not opt.dest_branch and merge_branch and merge_branch != full_dest: 470 if not opt.dest_branch and merge_branch and merge_branch != full_dest:
467 print('merge branch %s does not match destination branch %s' 471 print('merge branch %s does not match destination branch %s'
468 % (merge_branch, full_dest)) 472 % (merge_branch, full_dest))