diff options
-rw-r--r-- | project.py | 8 | ||||
-rw-r--r-- | subcmds/upload.py | 6 |
2 files changed, 8 insertions, 6 deletions
@@ -996,6 +996,13 @@ class Project(object): | |||
996 | if not branch.remote.review: | 996 | if not branch.remote.review: |
997 | raise GitError('remote %s has no review url' % branch.remote.name) | 997 | raise GitError('remote %s has no review url' % branch.remote.name) |
998 | 998 | ||
999 | # Basic validity check on label syntax. | ||
1000 | for label in labels: | ||
1001 | if not re.match(r'^.+[+-][0-9]+$', label): | ||
1002 | raise UploadError( | ||
1003 | f'invalid label syntax "{label}": labels use forms like ' | ||
1004 | 'CodeReview+1 or Verified-1') | ||
1005 | |||
999 | if dest_branch is None: | 1006 | if dest_branch is None: |
1000 | dest_branch = self.dest_branch | 1007 | dest_branch = self.dest_branch |
1001 | if dest_branch is None: | 1008 | if dest_branch is None: |
@@ -1031,6 +1038,7 @@ class Project(object): | |||
1031 | if auto_topic: | 1038 | if auto_topic: |
1032 | opts += ['topic=' + branch.name] | 1039 | opts += ['topic=' + branch.name] |
1033 | opts += ['t=%s' % p for p in hashtags] | 1040 | opts += ['t=%s' % p for p in hashtags] |
1041 | # NB: No need to encode labels as they've been validated above. | ||
1034 | opts += ['l=%s' % p for p in labels] | 1042 | opts += ['l=%s' % p for p in labels] |
1035 | 1043 | ||
1036 | opts += ['r=%s' % p for p in people[0]] | 1044 | opts += ['r=%s' % p for p in people[0]] |
diff --git a/subcmds/upload.py b/subcmds/upload.py index ef3d8e9d..20b8fe5d 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -421,12 +421,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
421 | labels = set(_ExpandCommaList(branch.project.config.GetString(key))) | 421 | labels = set(_ExpandCommaList(branch.project.config.GetString(key))) |
422 | for label in opt.labels: | 422 | for label in opt.labels: |
423 | labels.update(_ExpandCommaList(label)) | 423 | labels.update(_ExpandCommaList(label)) |
424 | # Basic sanity check on label syntax. | ||
425 | for label in labels: | ||
426 | if not re.match(r'^.+[+-][0-9]+$', label): | ||
427 | print('repo: error: invalid label syntax "%s": labels use forms ' | ||
428 | 'like CodeReview+1 or Verified-1' % (label,), file=sys.stderr) | ||
429 | sys.exit(1) | ||
430 | 424 | ||
431 | # Handle e-mail notifications. | 425 | # Handle e-mail notifications. |
432 | if opt.notify is False: | 426 | if opt.notify is False: |