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