upload: respect --yes with large upload confirmation

If the user passes in --yes, don't prompt them to confirm large uploads.

Bug: https://crbug.com/gerrit/14085
Change-Id: Ic801b21be80ba181801531acd4af5057ec10c11c
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343554
Reviewed-by: LaMont Jones <lamontjones@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger 2022-08-19 07:26:38 -04:00
parent d75ca2eb9d
commit e6d4b84060

View File

@ -262,7 +262,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
answer = sys.stdin.readline().strip().lower() answer = sys.stdin.readline().strip().lower()
answer = answer in ('y', 'yes', '1', 'true', 't') answer = answer in ('y', 'yes', '1', 'true', 't')
if answer: if not opt.yes and answer:
if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD:
answer = _ConfirmManyUploads() answer = _ConfirmManyUploads()
@ -335,14 +335,15 @@ Gerrit Code Review: https://www.gerritcodereview.com/
if not todo: if not todo:
_die("nothing uncommented for upload") _die("nothing uncommented for upload")
many_commits = False if not opt.yes:
for branch in todo: many_commits = False
if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: for branch in todo:
many_commits = True if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD:
break many_commits = True
if many_commits: break
if not _ConfirmManyUploads(multiple_branches=True): if many_commits:
_die("upload aborted by user") if not _ConfirmManyUploads(multiple_branches=True):
_die("upload aborted by user")
self._UploadAndReport(opt, todo, people) self._UploadAndReport(opt, todo, people)