summaryrefslogtreecommitdiffstats
path: root/subcmds/upload.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r--subcmds/upload.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py
index dc7e26da..9c279230 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -484,19 +484,24 @@ Gerrit Code Review: https://www.gerritcodereview.com/
484 484
485 destination = opt.dest_branch or branch.project.dest_branch 485 destination = opt.dest_branch or branch.project.dest_branch
486 486
487 # Make sure our local branch is not setup to track a different remote branch 487 if branch.project.dest_branch and not opt.dest_branch:
488 merge_branch = self._GetMergeBranch(branch.project) 488
489 if destination: 489 merge_branch = self._GetMergeBranch(
490 branch.project, local_branch=branch.name)
491
490 full_dest = destination 492 full_dest = destination
491 if not full_dest.startswith(R_HEADS): 493 if not full_dest.startswith(R_HEADS):
492 full_dest = R_HEADS + full_dest 494 full_dest = R_HEADS + full_dest
493 495
494 if not opt.dest_branch and merge_branch and merge_branch != full_dest: 496 # If the merge branch of the local branch is different from the
495 print('merge branch %s does not match destination branch %s' 497 # project's revision AND destination, this might not be intentional.
496 % (merge_branch, full_dest)) 498 if (merge_branch and merge_branch != branch.project.revisionExpr
499 and merge_branch != full_dest):
500 print(f'For local branch {branch.name}: merge branch '
501 f'{merge_branch} does not match destination branch '
502 f'{destination}')
497 print('skipping upload.') 503 print('skipping upload.')
498 print('Please use `--destination %s` if this is intentional' 504 print(f'Please use `--destination {destination}` if this is intentional')
499 % destination)
500 branch.uploaded = False 505 branch.uploaded = False
501 continue 506 continue
502 507
@@ -546,13 +551,14 @@ Gerrit Code Review: https://www.gerritcodereview.com/
546 if have_errors: 551 if have_errors:
547 sys.exit(1) 552 sys.exit(1)
548 553
549 def _GetMergeBranch(self, project): 554 def _GetMergeBranch(self, project, local_branch=None):
550 p = GitCommand(project, 555 if local_branch is None:
551 ['rev-parse', '--abbrev-ref', 'HEAD'], 556 p = GitCommand(project,
552 capture_stdout=True, 557 ['rev-parse', '--abbrev-ref', 'HEAD'],
553 capture_stderr=True) 558 capture_stdout=True,
554 p.Wait() 559 capture_stderr=True)
555 local_branch = p.stdout.strip() 560 p.Wait()
561 local_branch = p.stdout.strip()
556 p = GitCommand(project, 562 p = GitCommand(project,
557 ['config', '--get', 'branch.%s.merge' % local_branch], 563 ['config', '--get', 'branch.%s.merge' % local_branch],
558 capture_stdout=True, 564 capture_stdout=True,