mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
upload: move label validation to core function
This way we know we don't need to encode the labels. Change-Id: Ib83ed8f4ed05f00b9d2d06a9dd3f304e4443430e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/337518 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: LaMont Jones <lamontjones@google.com>
This commit is contained in:
parent
74737da1ab
commit
3a0a145b0e
@ -996,6 +996,13 @@ class Project(object):
|
|||||||
if not branch.remote.review:
|
if not branch.remote.review:
|
||||||
raise GitError('remote %s has no review url' % branch.remote.name)
|
raise GitError('remote %s has no review url' % branch.remote.name)
|
||||||
|
|
||||||
|
# Basic validity check on label syntax.
|
||||||
|
for label in labels:
|
||||||
|
if not re.match(r'^.+[+-][0-9]+$', label):
|
||||||
|
raise UploadError(
|
||||||
|
f'invalid label syntax "{label}": labels use forms like '
|
||||||
|
'CodeReview+1 or Verified-1')
|
||||||
|
|
||||||
if dest_branch is None:
|
if dest_branch is None:
|
||||||
dest_branch = self.dest_branch
|
dest_branch = self.dest_branch
|
||||||
if dest_branch is None:
|
if dest_branch is None:
|
||||||
@ -1031,6 +1038,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]
|
||||||
|
# NB: No need to encode labels as they've been validated above.
|
||||||
opts += ['l=%s' % p for p in labels]
|
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]]
|
||||||
|
@ -421,12 +421,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
labels = set(_ExpandCommaList(branch.project.config.GetString(key)))
|
labels = set(_ExpandCommaList(branch.project.config.GetString(key)))
|
||||||
for label in opt.labels:
|
for label in opt.labels:
|
||||||
labels.update(_ExpandCommaList(label))
|
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)
|
|
||||||
|
|
||||||
# Handle e-mail notifications.
|
# Handle e-mail notifications.
|
||||||
if opt.notify is False:
|
if opt.notify is False:
|
||||||
|
Loading…
Reference in New Issue
Block a user