Merge "feat(cmd): add hashtag implementation"
This commit is contained in:
commit
3fbead8637
@ -1445,14 +1445,28 @@ class MalformedInput(GitReviewException):
|
||||
EXIT_CODE = 3
|
||||
|
||||
|
||||
def assert_valid_hashtags(hashtags):
|
||||
"""Ensure no whitespace is found in hashtags, as it will result
|
||||
in an invalid refspec.
|
||||
"""
|
||||
assert_valid_whitespace(hashtags, "hashtags")
|
||||
|
||||
|
||||
def assert_valid_reviewers(reviewers):
|
||||
"""Ensure no whitespace is found in reviewer names, as it will result
|
||||
in an invalid refspec.
|
||||
"""
|
||||
for reviewer in reviewers:
|
||||
if re.search(r'\s', reviewer):
|
||||
assert_valid_whitespace(reviewers, "reviewers")
|
||||
|
||||
|
||||
def assert_valid_whitespace(values, type_name):
|
||||
"""Ensure no whitespace is found in list values, as it will result
|
||||
in an invalid refspec.
|
||||
"""
|
||||
for v in values:
|
||||
if re.search(r"\s", v):
|
||||
raise MalformedInput(
|
||||
"Whitespace not allowed in reviewer: '%s'" % reviewer)
|
||||
"Whitespace not allowed in %s: '%s'" % type_name, v)
|
||||
|
||||
|
||||
class _DownloadFlag(argparse.Action):
|
||||
@ -1529,6 +1543,8 @@ additional information:
|
||||
action="store_true",
|
||||
help="No topic except if explicitly provided")
|
||||
|
||||
parser.add_argument("--hashtags", nargs="+",
|
||||
help="Hashtags to submit branch to")
|
||||
parser.add_argument("--reviewers", nargs="+",
|
||||
help="Add reviewers to uploaded patch sets.")
|
||||
parser.add_argument("-n", "--dry-run", dest="dry", action="store_true",
|
||||
@ -1803,6 +1819,10 @@ additional information:
|
||||
if topic and topic != branch:
|
||||
push_options.append("topic=%s" % topic)
|
||||
|
||||
if options.hashtags:
|
||||
assert_valid_hashtags(options.hashtags)
|
||||
push_options += ["t=%s" % r for r in options.hashtags]
|
||||
|
||||
if options.reviewers:
|
||||
assert_valid_reviewers(options.reviewers)
|
||||
push_options += ["r=%s" % r for r in options.reviewers]
|
||||
|
Loading…
x
Reference in New Issue
Block a user