Skip to content

Commit c4af2b0

Browse files
bitluxgopherbot
authored andcommitted
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-on: https://go-review.googlesource.com/c/review/+/681176 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Junyang Shao <[email protected]> Reviewed-by: Sean Liao <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Sean Liao <[email protected]>
1 parent d5c513c commit c4af2b0

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

git-codereview/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func hookGofmt() {
355355
return
356356
}
357357

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

git-codereview/hook_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ func TestHookPreCommit(t *testing.T) {
239239
trun(t, gt.client, "git", "add", ".")
240240

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

245245
write(t, gt.client+"/broken.go", brokenGo, 0644)
246246
trun(t, gt.client, "git", "add", "broken.go")
247247
testMainDied(t, "hook-invoke", "pre-commit")
248-
testPrintedStderr(t, "gofmt needs to format these files (run 'git gofmt'):",
248+
testPrintedStderr(t, "gofmt needs to format these files (run 'git codereview gofmt'):",
249249
"bad.go", "!good.go", fromSlash("!test/bad"), fromSlash("test/bench/bad.go"),
250250
"gofmt reported errors:", "broken.go")
251251
}
@@ -265,19 +265,19 @@ func TestHookChangeGofmt(t *testing.T) {
265265

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

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

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

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

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

300300
/*
301301
OLD TEST, back when we disabled gofmt in detached head,

git-codereview/submit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ func cmdSubmit(args []string) {
6464
if len(cs) == 1 && len(b.Pending()) == 1 {
6565
if err := runErr("git", "checkout", "-q", "-B", b.Name, g.CurrentRevision, "--"); err != nil {
6666
dief("submit succeeded, but cannot sync local branch\n"+
67-
"\trun 'git sync' to sync, or\n"+
68-
"\trun 'git branch -D %s; git change master; git sync' to discard local branch", b.Name)
67+
"\trun 'git codereview sync' to sync, or\n"+
68+
"\trun 'git branch -D %s; git change master; git codereview sync' to discard local branch", b.Name)
6969
}
7070
} else {
71-
printf("submit succeeded; run 'git sync' to sync")
71+
printf("submit succeeded; run 'git codereview sync' to sync")
7272
}
7373

7474
// Done! Change is submitted, branch is up to date, ready for new work.
@@ -171,7 +171,7 @@ func submitCheck(g *GerritChange) error {
171171

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

176176
case "ABANDONED":
177177
return fmt.Errorf("change abandoned")

git-codereview/submit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestSubmitErrors(t *testing.T) {
7171
srv.setJSON(id, `{"status": "MERGED"}`)
7272
testMainDied(t, "submit")
7373
testRan(t) // nothing
74-
testPrintedStderr(t, "cannot submit: change already submitted, run 'git sync'")
74+
testPrintedStderr(t, "cannot submit: change already submitted, run 'git codereview sync'")
7575

7676
t.Logf("> abandoned")
7777
srv.setJSON(id, `{"status": "ABANDONED"}`)

git-codereview/sync.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func cmdSyncBranch(args []string) {
224224
other := cmdOutput("git", "log", "--format=format:+ %cd %h %s", "--date=short", "origin/"+branch+"..origin/"+parent)
225225
if other != "" {
226226
dief("cannot sync-branch --merge-back-to-parent: parent has new commits.\n"+
227-
"\trun 'git sync-branch' to bring them into this branch first:\n%s",
227+
"\trun 'git codereview sync-branch' to bring them into this branch first:\n%s",
228228
other)
229229
}
230230
}
@@ -293,7 +293,7 @@ func cmdSyncBranch(args []string) {
293293
dief("sync-branch: merge conflicts in:\n\t- %s\n\n"+
294294
"Please fix them (use 'git status' to see the list again),\n"+
295295
"then 'git add' or 'git rm' to resolve them,\n"+
296-
"and then 'git sync-branch -continue' to continue.\n"+
296+
"and then 'git codereview sync-branch -continue' to continue.\n"+
297297
"Or run 'git merge --abort' to give up on this sync-branch.\n",
298298
strings.Join(status.Conflicts, "\n\t- "))
299299
}
@@ -374,7 +374,7 @@ func syncBranchContinue(flag string, b *Branch, status *syncBranchStatus) {
374374
if HasUnstagedChanges() {
375375
dief("cannot sync-branch%s: unstaged changes (unresolved conflicts)\n"+
376376
"\tUse 'git status' to see them, 'git add' or 'git rm' to resolve them,\n"+
377-
"\tand then run 'git sync-branch -continue' again.\n", flag)
377+
"\tand then run 'git codereview sync-branch -continue' again.\n", flag)
378378
}
379379

380380
run("git", "commit", "-m", msg)

git-codereview/sync_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ func TestSyncBranchConflict(t *testing.T) {
364364
" - file",
365365
"Please fix them (use 'git status' to see the list again),",
366366
"then 'git add' or 'git rm' to resolve them,",
367-
"and then 'git sync-branch -continue' to continue.",
367+
"and then 'git codereview sync-branch -continue' to continue.",
368368
"Or run 'git merge --abort' to give up on this sync-branch.",
369369
)
370370

0 commit comments

Comments
 (0)