feat(cmd): add hashtag implementation
Change-Id: I1b4ab28bea9a8b2bb7501b1de7e3a080c87fe46d
This commit is contained in:
parent
e2382507ed
commit
ce909662d7
@ -1435,14 +1435,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):
|
||||
@ -1519,6 +1533,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",
|
||||
@ -1789,6 +1805,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