[review] git-codereview: explicitly include the codreview subcommand in suggested commands

6 views
Skip to first unread message

Adam Bender (Gerrit)

unread,
Jun 11, 2025, 10:16:44 PM6/11/25
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Adam Bender has uploaded the change for review

Commit message

git-codereview: explicitly include the codreview subcommand in suggested commands

If a user does not have the recommended aliases in their .gitconfig, the suggested
command will not work. Several suggestions have the codereview subcommand already;
this change updates all suggestions to include it.
Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca

Change diff

diff --git a/git-codereview/hook.go b/git-codereview/hook.go
index 162e4d1..be2b699 100644
--- a/git-codereview/hook.go
+++ b/git-codereview/hook.go
@@ -355,7 +355,7 @@
return
}

- dief("gofmt needs to format these files (run 'git gofmt'):\n\t%s",
+ dief("gofmt needs to format these files (run 'git codereview gofmt'):\n\t%s",
strings.Join(files, "\n\t"))
}

diff --git a/git-codereview/hook_test.go b/git-codereview/hook_test.go
index 218b425..0c1e5cb 100644
--- a/git-codereview/hook_test.go
+++ b/git-codereview/hook_test.go
@@ -239,13 +239,13 @@
trun(t, gt.client, "git", "add", ".")

testMainDied(t, "hook-invoke", "pre-commit")
- testPrintedStderr(t, "gofmt needs to format these files (run 'git gofmt'):",
+ testPrintedStderr(t, "gofmt needs to format these files (run 'git codereview gofmt'):",
"bad.go", "!good.go", fromSlash("!test/bad"), fromSlash("test/bench/bad.go"))

write(t, gt.client+"/broken.go", brokenGo, 0644)
trun(t, gt.client, "git", "add", "broken.go")
testMainDied(t, "hook-invoke", "pre-commit")
- testPrintedStderr(t, "gofmt needs to format these files (run 'git gofmt'):",
+ testPrintedStderr(t, "gofmt needs to format these files (run 'git codereview gofmt'):",
"bad.go", "!good.go", fromSlash("!test/bad"), fromSlash("test/bench/bad.go"),
"gofmt reported errors:", "broken.go")
}
@@ -265,19 +265,19 @@

t.Logf("invoking commit hook explicitly")
testMainDied(t, "hook-invoke", "pre-commit")
- testPrintedStderr(t, "gofmt needs to format these files (run 'git gofmt'):", "bad.go")
+ testPrintedStderr(t, "gofmt needs to format these files (run 'git codereview gofmt'):", "bad.go")

t.Logf("change without hook installed")
testCommitMsg = "foo: msg"
testMainDied(t, "change")
- testPrintedStderr(t, "gofmt needs to format these files (run 'git gofmt'):", "bad.go", "!running: git")
+ testPrintedStderr(t, "gofmt needs to format these files (run 'git codereview gofmt'):", "bad.go", "!running: git")

t.Logf("change with hook installed")
restore := testInstallHook(t, gt)
defer restore()
testCommitMsg = "foo: msg"
testMainDied(t, "change")
- testPrintedStderr(t, "gofmt needs to format these files (run 'git gofmt'):", "bad.go", "!running: git")
+ testPrintedStderr(t, "gofmt needs to format these files (run 'git codereview gofmt'):", "bad.go", "!running: git")
}

func TestHookPreCommitDetachedHead(t *testing.T) {
@@ -295,7 +295,7 @@
trun(t, gt.client, "git", "checkout", "HEAD^0")

testMainDied(t, "hook-invoke", "pre-commit")
- testPrintedStderr(t, "gofmt needs to format these files (run 'git gofmt'):", "bad.go")
+ testPrintedStderr(t, "gofmt needs to format these files (run 'git codereview gofmt'):", "bad.go")

/*
OLD TEST, back when we disabled gofmt in detached head,
diff --git a/git-codereview/submit.go b/git-codereview/submit.go
index fc02713..ce629c3 100644
--- a/git-codereview/submit.go
+++ b/git-codereview/submit.go
@@ -64,11 +64,11 @@
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"+
- "\trun 'git branch -D %s; git change master; git sync' to discard local branch", b.Name)
+ "\trun 'git codereview sync' to sync, or\n"+
+ "\trun 'git branch -D %s; git change master; git codereview sync' to discard local branch", b.Name)
}
} else {
- printf("submit succeeded; run 'git sync' to sync")
+ printf("submit succeeded; run 'git codereview sync' to sync")
}

// Done! Change is submitted, branch is up to date, ready for new work.
@@ -171,7 +171,7 @@

case "MERGED":
// Can happen if moving between different clients.
- return fmt.Errorf("change already submitted, run 'git sync'")
+ return fmt.Errorf("change already submitted, run 'git codereview sync'")

case "ABANDONED":
return fmt.Errorf("change abandoned")
diff --git a/git-codereview/submit_test.go b/git-codereview/submit_test.go
index 3e18fd8..657f6ba 100644
--- a/git-codereview/submit_test.go
+++ b/git-codereview/submit_test.go
@@ -71,7 +71,7 @@
srv.setJSON(id, `{"status": "MERGED"}`)
testMainDied(t, "submit")
testRan(t) // nothing
- testPrintedStderr(t, "cannot submit: change already submitted, run 'git sync'")
+ testPrintedStderr(t, "cannot submit: change already submitted, run 'git codereview sync'")

t.Logf("> abandoned")
srv.setJSON(id, `{"status": "ABANDONED"}`)
diff --git a/git-codereview/sync.go b/git-codereview/sync.go
index c60d04c..7b8fe26 100644
--- a/git-codereview/sync.go
+++ b/git-codereview/sync.go
@@ -224,7 +224,7 @@
other := cmdOutput("git", "log", "--format=format:+ %cd %h %s", "--date=short", "origin/"+branch+"..origin/"+parent)
if other != "" {
dief("cannot sync-branch --merge-back-to-parent: parent has new commits.\n"+
- "\trun 'git sync-branch' to bring them into this branch first:\n%s",
+ "\trun 'git codereview sync-branch' to bring them into this branch first:\n%s",
other)
}
}
@@ -293,7 +293,7 @@
dief("sync-branch: merge conflicts in:\n\t- %s\n\n"+
"Please fix them (use 'git status' to see the list again),\n"+
"then 'git add' or 'git rm' to resolve them,\n"+
- "and then 'git sync-branch -continue' to continue.\n"+
+ "and then 'git codereview sync-branch -continue' to continue.\n"+
"Or run 'git merge --abort' to give up on this sync-branch.\n",
strings.Join(status.Conflicts, "\n\t- "))
}
@@ -374,7 +374,7 @@
if HasUnstagedChanges() {
dief("cannot sync-branch%s: unstaged changes (unresolved conflicts)\n"+
"\tUse 'git status' to see them, 'git add' or 'git rm' to resolve them,\n"+
- "\tand then run 'git sync-branch -continue' again.\n", flag)
+ "\tand then run 'git codereview sync-branch -continue' again.\n", flag)
}

run("git", "commit", "-m", msg)
diff --git a/git-codereview/sync_test.go b/git-codereview/sync_test.go
index c073cbf..decb9a1 100644
--- a/git-codereview/sync_test.go
+++ b/git-codereview/sync_test.go
@@ -364,7 +364,7 @@
" - file",
"Please fix them (use 'git status' to see the list again),",
"then 'git add' or 'git rm' to resolve them,",
- "and then 'git sync-branch -continue' to continue.",
+ "and then 'git codereview sync-branch -continue' to continue.",
"Or run 'git merge --abort' to give up on this sync-branch.",
)

Change information

Files:
  • M git-codereview/hook.go
  • M git-codereview/hook_test.go
  • M git-codereview/submit.go
  • M git-codereview/submit_test.go
  • M git-codereview/sync.go
  • M git-codereview/sync_test.go
Change size: S
Delta: 6 files changed, 16 insertions(+), 16 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: review
Gerrit-Branch: master
Gerrit-Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca
Gerrit-Change-Number: 681176
Gerrit-PatchSet: 1
Gerrit-Owner: Adam Bender <abe...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Adam Bender (Gerrit)

unread,
Jun 12, 2025, 12:44:40 AM6/12/25
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Kevin Burke

Adam Bender uploaded new patchset

Adam Bender uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Kevin Burke
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: review
Gerrit-Branch: master
Gerrit-Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca
Gerrit-Change-Number: 681176
Gerrit-PatchSet: 2
Gerrit-Owner: Adam Bender <abe...@gmail.com>
Gerrit-Reviewer: Kevin Burke <ke...@burke.dev>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Kevin Burke <ke...@burke.dev>
unsatisfied_requirement
satisfied_requirement
open
diffy

Sean Liao (Gerrit)

unread,
Jun 16, 2025, 2:56:40 PM6/16/25
to Adam Bender, goph...@pubsubhelper.golang.org, Kevin Burke, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Adam Bender and Kevin Burke

Sean Liao voted

Auto-Submit+1
Code-Review+2
Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Adam Bender
  • Kevin Burke
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: review
Gerrit-Branch: master
Gerrit-Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca
Gerrit-Change-Number: 681176
Gerrit-PatchSet: 2
Gerrit-Owner: Adam Bender <abe...@gmail.com>
Gerrit-Reviewer: Kevin Burke <ke...@burke.dev>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Kevin Burke <ke...@burke.dev>
Gerrit-Attention: Adam Bender <abe...@gmail.com>
Gerrit-Comment-Date: Mon, 16 Jun 2025 18:56:27 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Junyang Shao (Gerrit)

unread,
Jun 17, 2025, 1:36:29 PM6/17/25
to Adam Bender, goph...@pubsubhelper.golang.org, Alan Donovan, Go LUCI, Kevin Burke, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Adam Bender and Kevin Burke

Junyang Shao voted and added 1 comment

Votes added by Junyang Shao

Code-Review+1

1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Junyang Shao . resolved

@adon...@google.com Does this look right?

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Bender
  • Kevin Burke
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: review
    Gerrit-Branch: master
    Gerrit-Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca
    Gerrit-Change-Number: 681176
    Gerrit-PatchSet: 2
    Gerrit-Owner: Adam Bender <abe...@gmail.com>
    Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
    Gerrit-Reviewer: Kevin Burke <ke...@burke.dev>
    Gerrit-Reviewer: Sean Liao <se...@liao.dev>
    Gerrit-CC: Alan Donovan <adon...@google.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Attention: Kevin Burke <ke...@burke.dev>
    Gerrit-Attention: Adam Bender <abe...@gmail.com>
    Gerrit-Comment-Date: Tue, 17 Jun 2025 17:36:25 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Cherry Mui (Gerrit)

    unread,
    Jun 17, 2025, 1:39:10 PM6/17/25
    to Adam Bender, goph...@pubsubhelper.golang.org, Junyang Shao, Alan Donovan, Go LUCI, Kevin Burke, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Adam Bender and Kevin Burke

    Cherry Mui voted Code-Review+2

    Code-Review+2
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Bender
    • Kevin Burke
    Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: review
      Gerrit-Branch: master
      Gerrit-Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca
      Gerrit-Change-Number: 681176
      Gerrit-PatchSet: 2
      Gerrit-Owner: Adam Bender <abe...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
      Gerrit-Reviewer: Kevin Burke <ke...@burke.dev>
      Gerrit-Reviewer: Sean Liao <se...@liao.dev>
      Gerrit-CC: Alan Donovan <adon...@google.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-Attention: Kevin Burke <ke...@burke.dev>
      Gerrit-Attention: Adam Bender <abe...@gmail.com>
      Gerrit-Comment-Date: Tue, 17 Jun 2025 17:39:05 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Gopher Robot (Gerrit)

      unread,
      Jun 17, 2025, 1:40:42 PM6/17/25
      to Adam Bender, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Cherry Mui, Junyang Shao, Alan Donovan, Go LUCI, Kevin Burke, golang-co...@googlegroups.com

      Gopher Robot submitted the change

      Change information

      Commit message:
      git-codereview: explicitly include the codereview subcommand in suggested commands


      If a user does not have the recommended aliases in their .gitconfig, the suggested
      command will not work. Several suggestions have the codereview subcommand already;
      this change updates all suggestions to include it.
      Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca
      Reviewed-by: Junyang Shao <shaoj...@google.com>
      Reviewed-by: Sean Liao <se...@liao.dev>
      Reviewed-by: Cherry Mui <cher...@google.com>
      Auto-Submit: Sean Liao <se...@liao.dev>
      Files:
      • M git-codereview/hook.go
      • M git-codereview/hook_test.go
      • M git-codereview/submit.go
      • M git-codereview/submit_test.go
      • M git-codereview/sync.go
      • M git-codereview/sync_test.go
      Change size: S
      Delta: 6 files changed, 16 insertions(+), 16 deletions(-)
      Branch: refs/heads/master
      Submit Requirements:
      • requirement satisfiedCode-Review: +2 by Cherry Mui, +2 by Sean Liao, +1 by Junyang Shao
      • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: review
      Gerrit-Branch: master
      Gerrit-Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca
      Gerrit-Change-Number: 681176
      Gerrit-PatchSet: 3
      Gerrit-Owner: Adam Bender <abe...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      open
      diffy
      satisfied_requirement

      Alan Donovan (Gerrit)

      unread,
      4:18 PM (2 hours ago) 4:18 PM
      to Gopher Robot, Adam Bender, goph...@pubsubhelper.golang.org, Cherry Mui, Junyang Shao, Go LUCI, Kevin Burke, golang-co...@googlegroups.com

      Alan Donovan added 1 comment

      Patchset-level comments
      File-level comment, Patchset 3 (Latest):
      Alan Donovan . resolved

      Thanks for fixing this. I was frequently annoyed by the wrong command, but at least I remembered the workaround; however my coding assistant (gemini) has no clue. Funny how the robots are getting us into better habits of writing documentation. ;-)

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: review
      Gerrit-Branch: master
      Gerrit-Change-Id: I3613f24172c2d90a7038f263cad93cbdcddbbbca
      Gerrit-Change-Number: 681176
      Gerrit-PatchSet: 3
      Gerrit-Owner: Adam Bender <abe...@gmail.com>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
      Gerrit-Reviewer: Kevin Burke <ke...@burke.dev>
      Gerrit-Reviewer: Sean Liao <se...@liao.dev>
      Gerrit-CC: Alan Donovan <adon...@google.com>
      Gerrit-Comment-Date: Fri, 27 Feb 2026 21:17:59 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages