upload: add config setting for upload notifications

This allows people to set default e-mail notifications via gitconfig.

Bug: https://crbug.com/gerrit/12451
Change-Id: Ic04ea3b7df0c5603c491961112c5be8cabb9dddd
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259014
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
Mike Frysinger 2020-03-14 17:39:03 -04:00 committed by David Pursehouse
parent 4847e05743
commit f725e548db
2 changed files with 15 additions and 1 deletions

View File

@ -195,6 +195,7 @@ The `[branch]` settings are updated by `repo start` and `git branch`.
| review.\<url\>.autoupload | upload | Automatically answer "yes" or "no" to all prompts | | review.\<url\>.autoupload | upload | Automatically answer "yes" or "no" to all prompts |
| review.\<url\>.uploadhashtags | upload | Automatically add to `--hashtag=<value>` | | review.\<url\>.uploadhashtags | upload | Automatically add to `--hashtag=<value>` |
| review.\<url\>.uploadlabels | upload | Automatically add to `--label=<value>` | | review.\<url\>.uploadlabels | upload | Automatically add to `--label=<value>` |
| review.\<url\>.uploadnotify | upload | [Notify setting][upload-notify] to use |
| review.\<url\>.uploadtopic | upload | Default [topic] to use | | review.\<url\>.uploadtopic | upload | Default [topic] to use |
| review.\<url\>.username | upload | Override username with `ssh://` review URIs | | review.\<url\>.username | upload | Override username with `ssh://` review URIs |
| remote.\<remote\>.fetch | sync | Set of refs to fetch | | remote.\<remote\>.fetch | sync | Set of refs to fetch |
@ -227,3 +228,4 @@ Repo will create & maintain a few files in the user's home directory.
[manifest-format.md]: ./manifest-format.md [manifest-format.md]: ./manifest-format.md
[local manifests]: ./manifest-format.md#Local-Manifests [local manifests]: ./manifest-format.md#Local-Manifests
[topic]: https://gerrit-review.googlesource.com/Documentation/intro-user.html#topics [topic]: https://gerrit-review.googlesource.com/Documentation/intro-user.html#topics
[upload-notify]: https://gerrit-review.googlesource.com/Documentation/user-upload.html#notify

View File

@ -142,6 +142,11 @@ To add labels whenever uploading a commit, you can set a per-project
or global Git option to do so. The value of review.URL.uploadlabels or global Git option to do so. The value of review.URL.uploadlabels
will be used as comma delimited labels like the --label option. will be used as comma delimited labels like the --label option.
review.URL.uploadnotify:
Control e-mail notifications when uploading.
https://gerrit-review.googlesource.com/Documentation/user-upload.html#notify
# References # References
Gerrit Code Review: https://www.gerritcodereview.com/ Gerrit Code Review: https://www.gerritcodereview.com/
@ -445,6 +450,13 @@ Gerrit Code Review: https://www.gerritcodereview.com/
'like CodeReview+1 or Verified-1' % (label,), file=sys.stderr) 'like CodeReview+1 or Verified-1' % (label,), file=sys.stderr)
sys.exit(1) sys.exit(1)
# Handle e-mail notifications.
if opt.notify is False:
notify = 'NONE'
else:
key = 'review.%s.uploadnotify' % branch.project.remote.review
notify = branch.project.config.GetString(key)
destination = opt.dest_branch or branch.project.dest_branch destination = opt.dest_branch or branch.project.dest_branch
# Make sure our local branch is not setup to track a different remote branch # Make sure our local branch is not setup to track a different remote branch
@ -466,7 +478,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
hashtags=hashtags, hashtags=hashtags,
labels=labels, labels=labels,
private=opt.private, private=opt.private,
notify=None if opt.notify else 'NONE', notify=notify,
wip=opt.wip, wip=opt.wip,
dest_branch=destination, dest_branch=destination,
validate_certs=opt.validate_certs, validate_certs=opt.validate_certs,