Skip to content

Commit 87f52f3

Browse files
vapierLUCI
authored and
LUCI
committed
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 <[email protected]> Reviewed-by: Gavin Mak <[email protected]> Commit-Queue: Mike Frysinger <[email protected]>
1 parent 562cea7 commit 87f52f3

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

man/repo-upload.1

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
2-
.TH REPO "1" "April 2024" "repo upload" "Repo Manual"
2+
.TH REPO "1" "June 2024" "repo upload" "Repo Manual"
33
.SH NAME
44
repo \- repo upload - manual page for repo upload
55
.SH SYNOPSIS
@@ -18,8 +18,11 @@ show this help message and exit
1818
number of jobs to run in parallel (default: based on
1919
number of CPU cores)
2020
.TP
21-
\fB\-t\fR
22-
send local branch name to Gerrit Code Review
21+
\fB\-t\fR, \fB\-\-topic\-branch\fR
22+
set the topic to the local branch name
23+
.TP
24+
\fB\-\-topic\fR=\fI\,TOPIC\/\fR
25+
set topic for the change
2326
.TP
2427
\fB\-\-hashtag\fR=\fI\,HASHTAGS\/\fR, \fB\-\-ht\fR=\fI\,HASHTAGS\/\fR
2528
add hashtags (comma delimited) to the review

project.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def UploadForReview(
257257
self,
258258
people,
259259
dryrun=False,
260-
auto_topic=False,
260+
topic=None,
261261
hashtags=(),
262262
labels=(),
263263
private=False,
@@ -273,7 +273,7 @@ def UploadForReview(
273273
branch=self.name,
274274
people=people,
275275
dryrun=dryrun,
276-
auto_topic=auto_topic,
276+
topic=topic,
277277
hashtags=hashtags,
278278
labels=labels,
279279
private=private,
@@ -1104,7 +1104,7 @@ def UploadForReview(
11041104
branch=None,
11051105
people=([], []),
11061106
dryrun=False,
1107-
auto_topic=False,
1107+
topic=None,
11081108
hashtags=(),
11091109
labels=(),
11101110
private=False,
@@ -1180,8 +1180,8 @@ def UploadForReview(
11801180

11811181
ref_spec = f"{R_HEADS + branch.name}:refs/for/{dest_branch}"
11821182
opts = []
1183-
if auto_topic:
1184-
opts += ["topic=" + branch.name]
1183+
if topic is not None:
1184+
opts += [f"topic={topic}"]
11851185
opts += ["t=%s" % p for p in hashtags]
11861186
# NB: No need to encode labels as they've been validated above.
11871187
opts += ["l=%s" % p for p in labels]

subcmds/upload.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,14 @@ class Upload(InteractiveCommand):
218218
def _Options(self, p):
219219
p.add_option(
220220
"-t",
221+
"--topic-branch",
221222
dest="auto_topic",
222223
action="store_true",
223-
help="send local branch name to Gerrit Code Review",
224+
help="set the topic to the local branch name",
225+
)
226+
p.add_option(
227+
"--topic",
228+
help="set topic for the change",
224229
)
225230
p.add_option(
226231
"--hashtag",
@@ -551,9 +556,12 @@ def _UploadBranch(self, opt, branch, original_people):
551556

552557
# Check if topic branches should be sent to the server during
553558
# upload.
554-
if opt.auto_topic is not True:
555-
key = "review.%s.uploadtopic" % branch.project.remote.review
556-
opt.auto_topic = branch.project.config.GetBoolean(key)
559+
if opt.topic is None:
560+
if opt.auto_topic is not True:
561+
key = "review.%s.uploadtopic" % branch.project.remote.review
562+
opt.auto_topic = branch.project.config.GetBoolean(key)
563+
if opt.auto_topic:
564+
opt.topic = branch.name
557565

558566
def _ExpandCommaList(value):
559567
"""Split |value| up into comma delimited entries."""
@@ -620,7 +628,7 @@ def _ExpandCommaList(value):
620628
branch.UploadForReview(
621629
people,
622630
dryrun=opt.dryrun,
623-
auto_topic=opt.auto_topic,
631+
topic=opt.topic,
624632
hashtags=hashtags,
625633
labels=labels,
626634
private=opt.private,

0 commit comments

Comments
 (0)