diff options
| -rw-r--r-- | subcmds/upload.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index 5c12aaee..f4633310 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -168,6 +168,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
| 168 | type='string', action='store', dest='dest_branch', | 168 | type='string', action='store', dest='dest_branch', |
| 169 | metavar='BRANCH', | 169 | metavar='BRANCH', |
| 170 | help='Submit for review on this target branch.') | 170 | help='Submit for review on this target branch.') |
| 171 | p.add_option('--no-cert-checks', | ||
| 172 | dest='validate_certs', action='store_false', default=True, | ||
| 173 | help='Disable verifying ssl certs (unsafe).') | ||
| 171 | 174 | ||
| 172 | # Options relating to upload hook. Note that verify and no-verify are NOT | 175 | # Options relating to upload hook. Note that verify and no-verify are NOT |
| 173 | # opposites of each other, which is why they store to different locations. | 176 | # opposites of each other, which is why they store to different locations. |
| @@ -185,15 +188,16 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
| 185 | # Never run upload hooks, but upload anyway (AKA bypass hooks). | 188 | # Never run upload hooks, but upload anyway (AKA bypass hooks). |
| 186 | # - no-verify=True, verify=True: | 189 | # - no-verify=True, verify=True: |
| 187 | # Invalid | 190 | # Invalid |
| 188 | p.add_option('--no-cert-checks', | 191 | g = p.add_option_group('Upload hooks') |
| 189 | dest='validate_certs', action='store_false', default=True, | 192 | g.add_option('--no-verify', |
| 190 | help='Disable verifying ssl certs (unsafe).') | ||
| 191 | p.add_option('--no-verify', | ||
| 192 | dest='bypass_hooks', action='store_true', | 193 | dest='bypass_hooks', action='store_true', |
| 193 | help='Do not run the upload hook.') | 194 | help='Do not run the upload hook.') |
| 194 | p.add_option('--verify', | 195 | g.add_option('--verify', |
| 195 | dest='allow_all_hooks', action='store_true', | 196 | dest='allow_all_hooks', action='store_true', |
| 196 | help='Run the upload hook without prompting.') | 197 | help='Run the upload hook without prompting.') |
| 198 | g.add_option('--ignore-hooks', | ||
| 199 | dest='ignore_hooks', action='store_true', | ||
| 200 | help='Do not abort uploading if upload hooks fail.') | ||
| 197 | 201 | ||
| 198 | def _SingleBranch(self, opt, branch, people): | 202 | def _SingleBranch(self, opt, branch, people): |
| 199 | project = branch.project | 203 | project = branch.project |
| @@ -488,12 +492,24 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
| 488 | abort_if_user_denies=True) | 492 | abort_if_user_denies=True) |
| 489 | pending_proj_names = [project.name for (project, available) in pending] | 493 | pending_proj_names = [project.name for (project, available) in pending] |
| 490 | pending_worktrees = [project.worktree for (project, available) in pending] | 494 | pending_worktrees = [project.worktree for (project, available) in pending] |
| 495 | passed = True | ||
| 491 | try: | 496 | try: |
| 492 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names, | 497 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names, |
| 493 | worktree_list=pending_worktrees) | 498 | worktree_list=pending_worktrees) |
| 499 | except SystemExit: | ||
| 500 | passed = False | ||
| 501 | if not opt.ignore_hooks: | ||
| 502 | raise | ||
| 494 | except HookError as e: | 503 | except HookError as e: |
| 504 | passed = False | ||
| 495 | print("ERROR: %s" % str(e), file=sys.stderr) | 505 | print("ERROR: %s" % str(e), file=sys.stderr) |
| 496 | return | 506 | |
| 507 | if not passed: | ||
| 508 | if opt.ignore_hooks: | ||
| 509 | print('\nWARNING: pre-upload hooks failed, but uploading anyways.', | ||
| 510 | file=sys.stderr) | ||
| 511 | else: | ||
| 512 | return | ||
| 497 | 513 | ||
| 498 | if opt.reviewers: | 514 | if opt.reviewers: |
| 499 | reviewers = _SplitEmails(opt.reviewers) | 515 | reviewers = _SplitEmails(opt.reviewers) |
