From a2b90d2f6e29477343826a7b79798b588394f4aa Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Mon, 11 May 2020 06:16:42 +0100 Subject: git-codereview: add -wip flag to mail command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a -wip flag to the mail command to set the status of a change to work-in-progress. Per: https://gerrit-review.googlesource.com/Documentation/intro-user.html#wip Fixes golang/go#20991 Change-Id: I227beccb55570949e9b0f487d5394855611a118a Reviewed-on: https://go-review.googlesource.com/c/review/+/233237 Reviewed-by: Daniel Martí Reviewed-by: Andrew Bonventre --- git-codereview/doc.go | 4 +++- git-codereview/mail.go | 7 ++++++- git-codereview/mail_test.go | 13 +++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/git-codereview/doc.go b/git-codereview/doc.go index 7624909..8cf1e64 100644 --- a/git-codereview/doc.go +++ b/git-codereview/doc.go @@ -191,7 +191,7 @@ Mail The mail command starts the code review process for the pending change. - git codereview mail [-f] [-r email] [-cc email] [-trybot] [revision] + git codereview mail [-f] [-r email] [-cc email] [-trybot] [-wip] [revision] It pushes the pending change commit in the current branch to the Gerrit code review server and prints the URL for the change on the server. @@ -210,6 +210,8 @@ and then, in case of ambiguity, using the reviewer who appears most often. The -trybot flag runs the trybots on all new or updated changes. It is equivalent to setting the Run-Trybot+1 label from Gerrit. +The -wip flag sets the status of the change to work-in-progress. + The mail command fails if there are staged edits that are not committed. The -f flag overrides this behavior. diff --git a/git-codereview/mail.go b/git-codereview/mail.go index fd663af..52ef44a 100644 --- a/git-codereview/mail.go +++ b/git-codereview/mail.go @@ -18,6 +18,7 @@ func cmdMail(args []string) { var ( diff = flags.Bool("diff", false, "show change commit diff and don't upload or mail") force = flags.Bool("f", false, "mail even if there are staged changes") + wip = flags.Bool("wip", false, "set the status of a change to Work-in-Progress") topic = flags.String("topic", "", "set Gerrit topic") trybot = flags.Bool("trybot", false, "run trybots on the uploaded CLs") rList = new(stringList) // installed below @@ -30,7 +31,7 @@ func cmdMail(args []string) { flags.Var(tagList, "hashtag", "comma-separated list of tags to set") flags.Usage = func() { - fmt.Fprintf(stderr(), "Usage: %s mail %s [-r reviewer,...] [-cc mail,...] [-nokeycheck] [-topic topic] [-trybot] [commit]\n", os.Args[0], globalFlags) + fmt.Fprintf(stderr(), "Usage: %s mail %s [-r reviewer,...] [-cc mail,...] [-nokeycheck] [-topic topic] [-trybot] [-wip] [commit]\n", os.Args[0], globalFlags) } flags.Parse(args) if len(flags.Args()) > 1 { @@ -136,6 +137,10 @@ func cmdMail(args []string) { refSpec += start + "l=Run-TryBot" start = "," } + if *wip { + refSpec += start + "wip" + start = "," + } args = []string{"push", "-q"} if *noKeyCheck { args = append(args, "-o", "nokeycheck") diff --git a/git-codereview/mail_test.go b/git-codereview/mail_test.go index 22d4747..c655b54 100644 --- a/git-codereview/mail_test.go +++ b/git-codereview/mail_test.go @@ -220,6 +220,19 @@ func TestMailShort(t *testing.T) { testPrintedStderr(t, "unknown reviewer: missing") } +func TestWIP(t *testing.T) { + gt := newGitTest(t) + defer gt.done() + gt.work(t) + + h := CurrentBranch().Pending()[0].ShortHash + + testMain(t, "mail", "-wip") + testRan(t, + "git push -q origin HEAD:refs/for/master%wip", + "git tag -f work.mailed "+h) +} + func TestMailTopic(t *testing.T) { gt := newGitTest(t) defer gt.done() -- cgit v1.3