summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2024-06-30 20:12:07 -0400
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-07-01 17:54:19 +0000
commit87f52f308c48c11a99cefcc308a0994abeb2a7ff (patch)
tree00f47a3ee2fa49753e562622c7f655788ad73bdd
parent562cea77580d5f217be73f21757c7d5b32d2d11f (diff)
downloadgit-repo-87f52f308c48c11a99cefcc308a0994abeb2a7ff.tar.gz
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>
-rw-r--r--man/repo-upload.19
-rw-r--r--project.py10
-rw-r--r--subcmds/upload.py18
3 files changed, 24 insertions, 13 deletions
diff --git a/man/repo-upload.1 b/man/repo-upload.1
index bb11dfa3..c0ae5816 100644
--- a/man/repo-upload.1
+++ b/man/repo-upload.1
@@ -1,5 +1,5 @@
1.\" DO NOT MODIFY THIS FILE! It was generated by help2man. 1.\" 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"
3.SH NAME 3.SH NAME
4repo \- repo upload - manual page for repo upload 4repo \- repo upload - manual page for repo upload
5.SH SYNOPSIS 5.SH SYNOPSIS
@@ -18,8 +18,11 @@ show this help message and exit
18number of jobs to run in parallel (default: based on 18number of jobs to run in parallel (default: based on
19number of CPU cores) 19number of CPU cores)
20.TP 20.TP
21\fB\-t\fR 21\fB\-t\fR, \fB\-\-topic\-branch\fR
22send local branch name to Gerrit Code Review 22set the topic to the local branch name
23.TP
24\fB\-\-topic\fR=\fI\,TOPIC\/\fR
25set topic for the change
23.TP 26.TP
24\fB\-\-hashtag\fR=\fI\,HASHTAGS\/\fR, \fB\-\-ht\fR=\fI\,HASHTAGS\/\fR 27\fB\-\-hashtag\fR=\fI\,HASHTAGS\/\fR, \fB\-\-ht\fR=\fI\,HASHTAGS\/\fR
25add hashtags (comma delimited) to the review 28add hashtags (comma delimited) to the review
diff --git a/project.py b/project.py
index 80a6c395..edf0723b 100644
--- a/project.py
+++ b/project.py
@@ -257,7 +257,7 @@ class ReviewableBranch:
257 self, 257 self,
258 people, 258 people,
259 dryrun=False, 259 dryrun=False,
260 auto_topic=False, 260 topic=None,
261 hashtags=(), 261 hashtags=(),
262 labels=(), 262 labels=(),
263 private=False, 263 private=False,
@@ -273,7 +273,7 @@ class ReviewableBranch:
273 branch=self.name, 273 branch=self.name,
274 people=people, 274 people=people,
275 dryrun=dryrun, 275 dryrun=dryrun,
276 auto_topic=auto_topic, 276 topic=topic,
277 hashtags=hashtags, 277 hashtags=hashtags,
278 labels=labels, 278 labels=labels,
279 private=private, 279 private=private,
@@ -1104,7 +1104,7 @@ class Project:
1104 branch=None, 1104 branch=None,
1105 people=([], []), 1105 people=([], []),
1106 dryrun=False, 1106 dryrun=False,
1107 auto_topic=False, 1107 topic=None,
1108 hashtags=(), 1108 hashtags=(),
1109 labels=(), 1109 labels=(),
1110 private=False, 1110 private=False,
@@ -1180,8 +1180,8 @@ class Project:
1180 1180
1181 ref_spec = f"{R_HEADS + branch.name}:refs/for/{dest_branch}" 1181 ref_spec = f"{R_HEADS + branch.name}:refs/for/{dest_branch}"
1182 opts = [] 1182 opts = []
1183 if auto_topic: 1183 if topic is not None:
1184 opts += ["topic=" + branch.name] 1184 opts += [f"topic={topic}"]
1185 opts += ["t=%s" % p for p in hashtags] 1185 opts += ["t=%s" % p for p in hashtags]
1186 # NB: No need to encode labels as they've been validated above. 1186 # NB: No need to encode labels as they've been validated above.
1187 opts += ["l=%s" % p for p in labels] 1187 opts += ["l=%s" % p for p in labels]
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 5b8c1a20..8039a1cd 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -218,9 +218,14 @@ Gerrit Code Review: https://www.gerritcodereview.com/
218 def _Options(self, p): 218 def _Options(self, p):
219 p.add_option( 219 p.add_option(
220 "-t", 220 "-t",
221 "--topic-branch",
221 dest="auto_topic", 222 dest="auto_topic",
222 action="store_true", 223 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",
224 ) 229 )
225 p.add_option( 230 p.add_option(
226 "--hashtag", 231 "--hashtag",
@@ -551,9 +556,12 @@ Gerrit Code Review: https://www.gerritcodereview.com/
551 556
552 # Check if topic branches should be sent to the server during 557 # Check if topic branches should be sent to the server during
553 # upload. 558 # upload.
554 if opt.auto_topic is not True: 559 if opt.topic is None:
555 key = "review.%s.uploadtopic" % branch.project.remote.review 560 if opt.auto_topic is not True:
556 opt.auto_topic = branch.project.config.GetBoolean(key) 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
557 565
558 def _ExpandCommaList(value): 566 def _ExpandCommaList(value):
559 """Split |value| up into comma delimited entries.""" 567 """Split |value| up into comma delimited entries."""
@@ -620,7 +628,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
620 branch.UploadForReview( 628 branch.UploadForReview(
621 people, 629 people,
622 dryrun=opt.dryrun, 630 dryrun=opt.dryrun,
623 auto_topic=opt.auto_topic, 631 topic=opt.topic,
624 hashtags=hashtags, 632 hashtags=hashtags,
625 labels=labels, 633 labels=labels,
626 private=opt.private, 634 private=opt.private,