mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
upload: allow users to set labels when uploading
Bug: https://crbug.com/gerrit/11801 Change-Id: I060465105b4e68ddfc815e572f62bf5dac2c1ffd Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256614 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
parent
d957ec6a83
commit
fc1b18ae9e
@ -193,7 +193,8 @@ The `[branch]` settings are updated by `repo start` and `git branch`.
|
|||||||
| review.\<url\>.autocopy | upload | Automatically add to `--cc=<value>` |
|
| review.\<url\>.autocopy | upload | Automatically add to `--cc=<value>` |
|
||||||
| review.\<url\>.autoreviewer | upload | Automatically add to `--reviewers=<value>` |
|
| review.\<url\>.autoreviewer | upload | Automatically add to `--reviewers=<value>` |
|
||||||
| 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 `--hashtags=<value>` |
|
| review.\<url\>.uploadhashtags | upload | Automatically add to `--hashtag=<value>` |
|
||||||
|
| review.\<url\>.uploadlabels | upload | Automatically add to `--label=<value>` |
|
||||||
| 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 |
|
||||||
|
@ -201,6 +201,7 @@ class ReviewableBranch(object):
|
|||||||
dryrun=False,
|
dryrun=False,
|
||||||
auto_topic=False,
|
auto_topic=False,
|
||||||
hashtags=(),
|
hashtags=(),
|
||||||
|
labels=(),
|
||||||
draft=False,
|
draft=False,
|
||||||
private=False,
|
private=False,
|
||||||
notify=None,
|
notify=None,
|
||||||
@ -213,6 +214,7 @@ class ReviewableBranch(object):
|
|||||||
dryrun=dryrun,
|
dryrun=dryrun,
|
||||||
auto_topic=auto_topic,
|
auto_topic=auto_topic,
|
||||||
hashtags=hashtags,
|
hashtags=hashtags,
|
||||||
|
labels=labels,
|
||||||
draft=draft,
|
draft=draft,
|
||||||
private=private,
|
private=private,
|
||||||
notify=notify,
|
notify=notify,
|
||||||
@ -1346,6 +1348,7 @@ class Project(object):
|
|||||||
dryrun=False,
|
dryrun=False,
|
||||||
auto_topic=False,
|
auto_topic=False,
|
||||||
hashtags=(),
|
hashtags=(),
|
||||||
|
labels=(),
|
||||||
draft=False,
|
draft=False,
|
||||||
private=False,
|
private=False,
|
||||||
notify=None,
|
notify=None,
|
||||||
@ -1406,6 +1409,7 @@ class Project(object):
|
|||||||
if auto_topic:
|
if auto_topic:
|
||||||
opts += ['topic=' + branch.name]
|
opts += ['topic=' + branch.name]
|
||||||
opts += ['t=%s' % p for p in hashtags]
|
opts += ['t=%s' % p for p in hashtags]
|
||||||
|
opts += ['l=%s' % p for p in labels]
|
||||||
|
|
||||||
opts += ['r=%s' % p for p in people[0]]
|
opts += ['r=%s' % p for p in people[0]]
|
||||||
opts += ['cc=%s' % p for p in people[1]]
|
opts += ['cc=%s' % p for p in people[1]]
|
||||||
|
@ -134,7 +134,13 @@ review.URL.uploadhashtags:
|
|||||||
|
|
||||||
To add hashtags whenever uploading a commit, you can set a per-project
|
To add hashtags whenever uploading a commit, you can set a per-project
|
||||||
or global Git option to do so. The value of review.URL.uploadhashtags
|
or global Git option to do so. The value of review.URL.uploadhashtags
|
||||||
will be used as comma delimited hashtags like the --hashtags option.
|
will be used as comma delimited hashtags like the --hashtag option.
|
||||||
|
|
||||||
|
review.URL.uploadlabels:
|
||||||
|
|
||||||
|
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
|
||||||
|
will be used as comma delimited labels like the --label option.
|
||||||
|
|
||||||
# References
|
# References
|
||||||
|
|
||||||
@ -152,6 +158,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
p.add_option('--hashtag-branch', '--htb',
|
p.add_option('--hashtag-branch', '--htb',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Add local branch name as a hashtag.')
|
help='Add local branch name as a hashtag.')
|
||||||
|
p.add_option('-l', '--label',
|
||||||
|
dest='labels', action='append', default=[],
|
||||||
|
help='Add a label when uploading.')
|
||||||
p.add_option('--re', '--reviewers',
|
p.add_option('--re', '--reviewers',
|
||||||
type='string', action='append', dest='reviewers',
|
type='string', action='append', dest='reviewers',
|
||||||
help='Request reviews from these people.')
|
help='Request reviews from these people.')
|
||||||
@ -410,22 +419,35 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
key = 'review.%s.uploadtopic' % branch.project.remote.review
|
key = 'review.%s.uploadtopic' % branch.project.remote.review
|
||||||
opt.auto_topic = branch.project.config.GetBoolean(key)
|
opt.auto_topic = branch.project.config.GetBoolean(key)
|
||||||
|
|
||||||
# Check if hashtags should be included.
|
def _ExpandCommaList(value):
|
||||||
def _ExpandHashtag(value):
|
"""Split |value| up into comma delimited entries."""
|
||||||
"""Split |value| up into comma delimited tags."""
|
|
||||||
if not value:
|
if not value:
|
||||||
return
|
return
|
||||||
for tag in value.split(','):
|
for ret in value.split(','):
|
||||||
tag = tag.strip()
|
ret = ret.strip()
|
||||||
if tag:
|
if ret:
|
||||||
yield tag
|
yield ret
|
||||||
|
|
||||||
|
# Check if hashtags should be included.
|
||||||
key = 'review.%s.uploadhashtags' % branch.project.remote.review
|
key = 'review.%s.uploadhashtags' % branch.project.remote.review
|
||||||
hashtags = set(_ExpandHashtag(branch.project.config.GetString(key)))
|
hashtags = set(_ExpandCommaList(branch.project.config.GetString(key)))
|
||||||
for tag in opt.hashtags:
|
for tag in opt.hashtags:
|
||||||
hashtags.update(_ExpandHashtag(tag))
|
hashtags.update(_ExpandCommaList(tag))
|
||||||
if opt.hashtag_branch:
|
if opt.hashtag_branch:
|
||||||
hashtags.add(branch.name)
|
hashtags.add(branch.name)
|
||||||
|
|
||||||
|
# Check if labels should be included.
|
||||||
|
key = 'review.%s.uploadlabels' % branch.project.remote.review
|
||||||
|
labels = set(_ExpandCommaList(branch.project.config.GetString(key)))
|
||||||
|
for label in opt.labels:
|
||||||
|
labels.update(_ExpandCommaList(label))
|
||||||
|
# Basic sanity check on label syntax.
|
||||||
|
for label in labels:
|
||||||
|
if not re.match(r'^.+[+-][0-9]+$', label):
|
||||||
|
print('repo: error: invalid label syntax "%s": labels use forms '
|
||||||
|
'like CodeReview+1 or Verified-1' % (label,), file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
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
|
||||||
@ -445,6 +467,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
dryrun=opt.dryrun,
|
dryrun=opt.dryrun,
|
||||||
auto_topic=opt.auto_topic,
|
auto_topic=opt.auto_topic,
|
||||||
hashtags=hashtags,
|
hashtags=hashtags,
|
||||||
|
labels=labels,
|
||||||
draft=opt.draft,
|
draft=opt.draft,
|
||||||
private=opt.private,
|
private=opt.private,
|
||||||
notify=None if opt.notify else 'NONE',
|
notify=None if opt.notify else 'NONE',
|
||||||
|
Loading…
Reference in New Issue
Block a user