diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/upload.py | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index 20822096..c561b8aa 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -19,7 +19,8 @@ import sys | |||
| 19 | 19 | ||
| 20 | from command import InteractiveCommand | 20 | from command import InteractiveCommand |
| 21 | from editor import Editor | 21 | from editor import Editor |
| 22 | from error import UploadError | 22 | from error import HookError, UploadError |
| 23 | from project import RepoHook | ||
| 23 | 24 | ||
| 24 | UNUSUAL_COMMIT_THRESHOLD = 5 | 25 | UNUSUAL_COMMIT_THRESHOLD = 5 |
| 25 | 26 | ||
| @@ -120,6 +121,29 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 120 | type='string', action='append', dest='cc', | 121 | type='string', action='append', dest='cc', |
| 121 | help='Also send email to these email addresses.') | 122 | help='Also send email to these email addresses.') |
| 122 | 123 | ||
| 124 | # Options relating to upload hook. Note that verify and no-verify are NOT | ||
| 125 | # opposites of each other, which is why they store to different locations. | ||
| 126 | # We are using them to match 'git commit' syntax. | ||
| 127 | # | ||
| 128 | # Combinations: | ||
| 129 | # - no-verify=False, verify=False (DEFAULT): | ||
| 130 | # If stdout is a tty, can prompt about running upload hooks if needed. | ||
| 131 | # If user denies running hooks, the upload is cancelled. If stdout is | ||
| 132 | # not a tty and we would need to prompt about upload hooks, upload is | ||
| 133 | # cancelled. | ||
| 134 | # - no-verify=False, verify=True: | ||
| 135 | # Always run upload hooks with no prompt. | ||
| 136 | # - no-verify=True, verify=False: | ||
| 137 | # Never run upload hooks, but upload anyway (AKA bypass hooks). | ||
| 138 | # - no-verify=True, verify=True: | ||
| 139 | # Invalid | ||
| 140 | p.add_option('--no-verify', | ||
| 141 | dest='bypass_hooks', action='store_true', | ||
| 142 | help='Do not run the upload hook.') | ||
| 143 | p.add_option('--verify', | ||
| 144 | dest='allow_all_hooks', action='store_true', | ||
| 145 | help='Run the upload hook without prompting.') | ||
| 146 | |||
| 123 | def _SingleBranch(self, opt, branch, people): | 147 | def _SingleBranch(self, opt, branch, people): |
| 124 | project = branch.project | 148 | project = branch.project |
| 125 | name = branch.name | 149 | name = branch.name |
| @@ -313,17 +337,27 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 313 | reviewers = [] | 337 | reviewers = [] |
| 314 | cc = [] | 338 | cc = [] |
| 315 | 339 | ||
| 340 | for project in project_list: | ||
| 341 | avail = project.GetUploadableBranches() | ||
| 342 | if avail: | ||
| 343 | pending.append((project, avail)) | ||
| 344 | |||
| 345 | if pending and (not opt.bypass_hooks): | ||
| 346 | hook = RepoHook('pre-upload', self.manifest.repo_hooks_project, | ||
| 347 | self.manifest.topdir, abort_if_user_denies=True) | ||
| 348 | pending_proj_names = [project.name for (project, avail) in pending] | ||
| 349 | try: | ||
| 350 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names) | ||
| 351 | except HookError, e: | ||
| 352 | print >>sys.stderr, "ERROR: %s" % str(e) | ||
| 353 | return | ||
| 354 | |||
| 316 | if opt.reviewers: | 355 | if opt.reviewers: |
| 317 | reviewers = _SplitEmails(opt.reviewers) | 356 | reviewers = _SplitEmails(opt.reviewers) |
| 318 | if opt.cc: | 357 | if opt.cc: |
| 319 | cc = _SplitEmails(opt.cc) | 358 | cc = _SplitEmails(opt.cc) |
| 320 | people = (reviewers,cc) | 359 | people = (reviewers,cc) |
| 321 | 360 | ||
| 322 | for project in project_list: | ||
| 323 | avail = project.GetUploadableBranches() | ||
| 324 | if avail: | ||
| 325 | pending.append((project, avail)) | ||
| 326 | |||
| 327 | if not pending: | 361 | if not pending: |
| 328 | print >>sys.stdout, "no branches ready for upload" | 362 | print >>sys.stdout, "no branches ready for upload" |
| 329 | elif len(pending) == 1 and len(pending[0][1]) == 1: | 363 | elif len(pending) == 1 and len(pending[0][1]) == 1: |
