summaryrefslogtreecommitdiffstats
path: root/subcmds/upload.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-19 02:22:22 -0500
committerMike Frysinger <vapier@google.com>2020-02-19 08:31:18 +0000
commit84685ba1875db265051cdd043d5dba768c7c42e5 (patch)
tree426cb29f23da77aac700bce1c08cba935d6f96aa /subcmds/upload.py
parent72ebf19e52e7c4b270e40ba07fec1048b3612797 (diff)
downloadgit-repo-84685ba1875db265051cdd043d5dba768c7c42e5.tar.gz
upload: add support for setting hashtags
This allows users to specify custom hashtags when uploading, both via the CLI and via the same gitconfig settings as other upload options. Bug: https://crbug.com/gerrit/11174 Change-Id: Ia0959e25b463e5f29d704e4d06e0de793d4fc77c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255855 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.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 91bec6f8..633ddc81 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -130,6 +130,12 @@ is set to "true" then repo will assume you always want the equivalent
130of the -t option to the repo command. If unset or set to "false" then 130of the -t option to the repo command. If unset or set to "false" then
131repo will make use of only the command line option. 131repo will make use of only the command line option.
132 132
133review.URL.uploadhashtags:
134
135To add hashtags whenever uploading a commit, you can set a per-project
136or global Git option to do so. The value of review.URL.uploadhashtags
137will be used as comma delimited hashtags like the --hashtags option.
138
133# References 139# References
134 140
135Gerrit Code Review: https://www.gerritcodereview.com/ 141Gerrit Code Review: https://www.gerritcodereview.com/
@@ -140,6 +146,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/
140 p.add_option('-t', 146 p.add_option('-t',
141 dest='auto_topic', action='store_true', 147 dest='auto_topic', action='store_true',
142 help='Send local branch name to Gerrit Code Review') 148 help='Send local branch name to Gerrit Code Review')
149 p.add_option('--hashtag', '--ht',
150 dest='hashtags', action='append', default=[],
151 help='Add hashtags (comma delimited) to the review.')
143 p.add_option('--re', '--reviewers', 152 p.add_option('--re', '--reviewers',
144 type='string', action='append', dest='reviewers', 153 type='string', action='append', dest='reviewers',
145 help='Request reviews from these people.') 154 help='Request reviews from these people.')
@@ -384,6 +393,20 @@ Gerrit Code Review: https://www.gerritcodereview.com/
384 key = 'review.%s.uploadtopic' % branch.project.remote.review 393 key = 'review.%s.uploadtopic' % branch.project.remote.review
385 opt.auto_topic = branch.project.config.GetBoolean(key) 394 opt.auto_topic = branch.project.config.GetBoolean(key)
386 395
396 # Check if hashtags should be included.
397 def _ExpandHashtag(value):
398 """Split |value| up into comma delimited tags."""
399 if not value:
400 return
401 for tag in value.split(','):
402 tag = tag.strip()
403 if tag:
404 yield tag
405 key = 'review.%s.uploadhashtags' % branch.project.remote.review
406 hashtags = set(_ExpandHashtag(branch.project.config.GetString(key)))
407 for tag in opt.hashtags:
408 hashtags.update(_ExpandHashtag(tag))
409
387 destination = opt.dest_branch or branch.project.dest_branch 410 destination = opt.dest_branch or branch.project.dest_branch
388 411
389 # Make sure our local branch is not setup to track a different remote branch 412 # Make sure our local branch is not setup to track a different remote branch
@@ -401,6 +424,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
401 424
402 branch.UploadForReview(people, 425 branch.UploadForReview(people,
403 auto_topic=opt.auto_topic, 426 auto_topic=opt.auto_topic,
427 hashtags=hashtags,
404 draft=opt.draft, 428 draft=opt.draft,
405 private=opt.private, 429 private=opt.private,
406 notify=None if opt.notify else 'NONE', 430 notify=None if opt.notify else 'NONE',