diff options
| author | Austin Clements <austin@google.com> | 2015-11-05 15:02:37 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2015-11-11 00:37:51 +0000 |
| commit | 0d7a1437b7262e6eb433008f1187ff729ac867ca (patch) | |
| tree | 9b323bdfc386a3e9adb7413774de73c90d18a56a /git-codereview/submit.go | |
| parent | 4a2b2fd69ccbe0e57e6bdecedacab520fd35b9c9 (diff) | |
| download | go-x-review-0d7a1437b7262e6eb433008f1187ff729ac867ca.tar.xz | |
git-codereview: allow multiple commit hashes for submit
This adds support to the submit subcommand for passing and submitting
multiple commit hashes.
Change-Id: Id030b07cac21d11acbeb8015fde9cb9e1acb1479
Reviewed-on: https://go-review.googlesource.com/16674
Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'git-codereview/submit.go')
| -rw-r--r-- | git-codereview/submit.go | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/git-codereview/submit.go b/git-codereview/submit.go index df43148..209f14b 100644 --- a/git-codereview/submit.go +++ b/git-codereview/submit.go @@ -14,20 +14,18 @@ import ( func cmdSubmit(args []string) { flags.Usage = func() { - fmt.Fprintf(stderr(), "Usage: %s submit %s [commit-hash]\n", os.Args[0], globalFlags) + fmt.Fprintf(stderr(), "Usage: %s submit %s [commit-hash...]\n", os.Args[0], globalFlags) } flags.Parse(args) - if n := len(flags.Args()); n > 1 { - flags.Usage() - os.Exit(2) - } b := CurrentBranch() - var c *Commit - if len(flags.Args()) == 1 { - c = b.CommitByHash("submit", flags.Arg(0)) + var cs []*Commit + if args := flags.Args(); len(args) >= 1 { + for _, arg := range args { + cs = append(cs, b.CommitByHash("submit", arg)) + } } else { - c = b.DefaultCommit("submit") + cs = append(cs, b.DefaultCommit("submit")) } // No staged changes. @@ -37,13 +35,17 @@ func cmdSubmit(args []string) { checkStaged("submit") checkUnstaged("submit") - // Submit the change. - g := submit(b, c) + // Submit the changes. + var g *GerritChange + for _, c := range cs { + printf("submitting %s %s", c.ShortHash, c.Subject) + g = submit(b, c) + } // Sync client to revision that Gerrit committed, but only if we can do it cleanly. // Otherwise require user to run 'git sync' themselves (if they care). run("git", "fetch", "-q") - if len(b.Pending()) == 1 { + if len(cs) == 1 && len(b.Pending()) == 1 { if err := runErr("git", "checkout", "-q", "-B", b.Name, g.CurrentRevision, "--"); err != nil { dief("submit succeeded, but cannot sync local branch\n"+ "\trun 'git sync' to sync, or\n"+ @@ -119,7 +121,8 @@ func submit(b *Branch, c *Commit) *GerritChange { } if *noRun { - dief("stopped before submit") + printf("stopped before submit") + return g } // Otherwise, try the submit. Sends back updated GerritChange, |
