mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
upload: add a --topic option for setting topic explicitly
Let people specify the exact topic when uploading CLs. The existing -t option only supports setting the topic to the current local branch. Add a --topic-branch long option to the existing -t to align it a bit better with --hashtag & --hashtag-branch. Change-Id: I010abc4a7f3c685021cae776dd1e597c22b79135 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/431997 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
562cea7758
commit
87f52f308c
@ -1,5 +1,5 @@
|
|||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
|
||||||
.TH REPO "1" "April 2024" "repo upload" "Repo Manual"
|
.TH REPO "1" "June 2024" "repo upload" "Repo Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
repo \- repo upload - manual page for repo upload
|
repo \- repo upload - manual page for repo upload
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -18,8 +18,11 @@ show this help message and exit
|
|||||||
number of jobs to run in parallel (default: based on
|
number of jobs to run in parallel (default: based on
|
||||||
number of CPU cores)
|
number of CPU cores)
|
||||||
.TP
|
.TP
|
||||||
\fB\-t\fR
|
\fB\-t\fR, \fB\-\-topic\-branch\fR
|
||||||
send local branch name to Gerrit Code Review
|
set the topic to the local branch name
|
||||||
|
.TP
|
||||||
|
\fB\-\-topic\fR=\fI\,TOPIC\/\fR
|
||||||
|
set topic for the change
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-hashtag\fR=\fI\,HASHTAGS\/\fR, \fB\-\-ht\fR=\fI\,HASHTAGS\/\fR
|
\fB\-\-hashtag\fR=\fI\,HASHTAGS\/\fR, \fB\-\-ht\fR=\fI\,HASHTAGS\/\fR
|
||||||
add hashtags (comma delimited) to the review
|
add hashtags (comma delimited) to the review
|
||||||
|
10
project.py
10
project.py
@ -257,7 +257,7 @@ class ReviewableBranch:
|
|||||||
self,
|
self,
|
||||||
people,
|
people,
|
||||||
dryrun=False,
|
dryrun=False,
|
||||||
auto_topic=False,
|
topic=None,
|
||||||
hashtags=(),
|
hashtags=(),
|
||||||
labels=(),
|
labels=(),
|
||||||
private=False,
|
private=False,
|
||||||
@ -273,7 +273,7 @@ class ReviewableBranch:
|
|||||||
branch=self.name,
|
branch=self.name,
|
||||||
people=people,
|
people=people,
|
||||||
dryrun=dryrun,
|
dryrun=dryrun,
|
||||||
auto_topic=auto_topic,
|
topic=topic,
|
||||||
hashtags=hashtags,
|
hashtags=hashtags,
|
||||||
labels=labels,
|
labels=labels,
|
||||||
private=private,
|
private=private,
|
||||||
@ -1104,7 +1104,7 @@ class Project:
|
|||||||
branch=None,
|
branch=None,
|
||||||
people=([], []),
|
people=([], []),
|
||||||
dryrun=False,
|
dryrun=False,
|
||||||
auto_topic=False,
|
topic=None,
|
||||||
hashtags=(),
|
hashtags=(),
|
||||||
labels=(),
|
labels=(),
|
||||||
private=False,
|
private=False,
|
||||||
@ -1180,8 +1180,8 @@ class Project:
|
|||||||
|
|
||||||
ref_spec = f"{R_HEADS + branch.name}:refs/for/{dest_branch}"
|
ref_spec = f"{R_HEADS + branch.name}:refs/for/{dest_branch}"
|
||||||
opts = []
|
opts = []
|
||||||
if auto_topic:
|
if topic is not None:
|
||||||
opts += ["topic=" + branch.name]
|
opts += [f"topic={topic}"]
|
||||||
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.
|
# 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]
|
||||||
|
@ -218,9 +218,14 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
def _Options(self, p):
|
def _Options(self, p):
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"-t",
|
"-t",
|
||||||
|
"--topic-branch",
|
||||||
dest="auto_topic",
|
dest="auto_topic",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="send local branch name to Gerrit Code Review",
|
help="set the topic to the local branch name",
|
||||||
|
)
|
||||||
|
p.add_option(
|
||||||
|
"--topic",
|
||||||
|
help="set topic for the change",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--hashtag",
|
"--hashtag",
|
||||||
@ -551,9 +556,12 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
|
|
||||||
# Check if topic branches should be sent to the server during
|
# Check if topic branches should be sent to the server during
|
||||||
# upload.
|
# upload.
|
||||||
|
if opt.topic is None:
|
||||||
if opt.auto_topic is not True:
|
if opt.auto_topic is not True:
|
||||||
key = "review.%s.uploadtopic" % branch.project.remote.review
|
key = "review.%s.uploadtopic" % branch.project.remote.review
|
||||||
opt.auto_topic = branch.project.config.GetBoolean(key)
|
opt.auto_topic = branch.project.config.GetBoolean(key)
|
||||||
|
if opt.auto_topic:
|
||||||
|
opt.topic = branch.name
|
||||||
|
|
||||||
def _ExpandCommaList(value):
|
def _ExpandCommaList(value):
|
||||||
"""Split |value| up into comma delimited entries."""
|
"""Split |value| up into comma delimited entries."""
|
||||||
@ -620,7 +628,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
branch.UploadForReview(
|
branch.UploadForReview(
|
||||||
people,
|
people,
|
||||||
dryrun=opt.dryrun,
|
dryrun=opt.dryrun,
|
||||||
auto_topic=opt.auto_topic,
|
topic=opt.topic,
|
||||||
hashtags=hashtags,
|
hashtags=hashtags,
|
||||||
labels=labels,
|
labels=labels,
|
||||||
private=opt.private,
|
private=opt.private,
|
||||||
|
Loading…
Reference in New Issue
Block a user