summaryrefslogtreecommitdiffstats
path: root/subcmds/upload.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-19 02:32:52 -0500
committerMike Frysinger <vapier@google.com>2020-02-19 16:04:14 +0000
commit02aa889ecd54d69fd6c3708d2e7f8654d57ac1e8 (patch)
tree56c2eb1940402e6a1355ca9032d27ed6806532e6 /subcmds/upload.py
parent819cc81c57848a1b2331c603c036547fad6caa75 (diff)
downloadgit-repo-02aa889ecd54d69fd6c3708d2e7f8654d57ac1e8.tar.gz
upload: add support for --yes
This adds a CLI option to the existing autoupload gitconfig knob that allows people to automatically answer "yes" to the various prompts. Bug: https://crbug.com/gerrit/12368 Change-Id: I819ebca01b9a40240b33866ae05907c7469703e3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255892 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r--subcmds/upload.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 6ef4955e..856c7fb9 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -184,6 +184,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/
184 p.add_option('-n', '--dry-run', 184 p.add_option('-n', '--dry-run',
185 dest='dryrun', default=False, action='store_true', 185 dest='dryrun', default=False, action='store_true',
186 help='Do everything except actually upload the CL.') 186 help='Do everything except actually upload the CL.')
187 p.add_option('-y', '--yes',
188 default=False, action='store_true',
189 help='Answer yes to all safe prompts.')
187 p.add_option('--no-cert-checks', 190 p.add_option('--no-cert-checks',
188 dest='validate_certs', action='store_false', default=True, 191 dest='validate_certs', action='store_false', default=True,
189 help='Disable verifying ssl certs (unsafe).') 192 help='Disable verifying ssl certs (unsafe).')
@@ -244,8 +247,12 @@ Gerrit Code Review: https://www.gerritcodereview.com/
244 print('to %s (y/N)? ' % remote.review, end='') 247 print('to %s (y/N)? ' % remote.review, end='')
245 # TODO: When we require Python 3, use flush=True w/print above. 248 # TODO: When we require Python 3, use flush=True w/print above.
246 sys.stdout.flush() 249 sys.stdout.flush()
247 answer = sys.stdin.readline().strip().lower() 250 if opt.yes:
248 answer = answer in ('y', 'yes', '1', 'true', 't') 251 print('<--yes>')
252 answer = True
253 else:
254 answer = sys.stdin.readline().strip().lower()
255 answer = answer in ('y', 'yes', '1', 'true', 't')
249 256
250 if answer: 257 if answer:
251 if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD: 258 if len(branch.commits) > UNUSUAL_COMMIT_THRESHOLD:
@@ -384,7 +391,11 @@ Gerrit Code Review: https://www.gerritcodereview.com/
384 print('Continue uploading? (y/N) ', end='') 391 print('Continue uploading? (y/N) ', end='')
385 # TODO: When we require Python 3, use flush=True w/print above. 392 # TODO: When we require Python 3, use flush=True w/print above.
386 sys.stdout.flush() 393 sys.stdout.flush()
387 a = sys.stdin.readline().strip().lower() 394 if opt.yes:
395 print('<--yes>')
396 a = 'yes'
397 else:
398 a = sys.stdin.readline().strip().lower()
388 if a not in ('y', 'yes', 't', 'true', 'on'): 399 if a not in ('y', 'yes', 't', 'true', 'on'):
389 print("skipping upload", file=sys.stderr) 400 print("skipping upload", file=sys.stderr)
390 branch.uploaded = False 401 branch.uploaded = False