Warn rather than fail if HEAD already exists on the remote

assert_one_change() would fail if it detects that HEAD exists on the
remote (on any branch at all).  However, some gerrit projects are
configured to allow such reviews to be opened so long as HEAD does not
exist on the target branch.  Start warning rather than failing and let
the gerrit server do its own check.

Story: 2010887
Task: 48652
Change-Id: I5040aa24d78abec31054d7eeee9f6f27ce538988
This commit is contained in:
James Muir 2023-09-18 21:25:47 -04:00
parent 21d9ceb5a5
commit 702a1dcfb2
1 changed files with 11 additions and 2 deletions

View File

@ -1016,9 +1016,18 @@ def assert_one_change(remote, branch, yes, have_hook):
"installed. Amending the commit to add a gerrit change id.")
run_command("git commit --amend", GIT_EDITOR='true')
elif output_lines == 0:
printwrap("No changes between HEAD and %s/%s. Submitting for review "
printwrap("The commit HEAD already exists on a branch on the remote. "
"If it already exists on %s/%s, then submitting for review "
"would be pointless." % (remote, branch))
sys.exit(1)
print("\n\n"
"Do you really want to submit this review?")
try:
yes_no = input("Type 'yes' to confirm, other to cancel: ")
except KeyboardInterrupt:
yes_no = "no"
if yes_no.lower().strip() != "yes":
print("Aborting.")
sys.exit(1)
elif output_lines > 1:
if not yes:
printwrap("You are about to submit multiple commits. This is "