From 702a1dcfb2406efba300d32eb490866dd15dcc0e Mon Sep 17 00:00:00 2001 From: James Muir Date: Mon, 18 Sep 2023 21:25:47 -0400 Subject: [PATCH] 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 --- git_review/cmd.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/git_review/cmd.py b/git_review/cmd.py index c879bf0f..20b419be 100644 --- a/git_review/cmd.py +++ b/git_review/cmd.py @@ -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 "