aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/util_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-01-07 12:26:06 -0500
committerRuss Cox <rsc@golang.org>2021-01-13 14:39:58 +0000
commit4aa052da7f65ad6eeb77cce14ef70dac82d242cc (patch)
tree774f94b2ae37b5e08a68504122663656f29e471c /git-codereview/util_test.go
parentc4d5d8fb54f168c51827b4901b8537fca9a2abc6 (diff)
downloadgo-x-review-4aa052da7f65ad6eeb77cce14ef70dac82d242cc.tar.xz
git-codereview: new sync-branch and related fixes
This CL adds a new command, "git codereview sync-branch", which does the appropriate git merge for the current branch. This CL also fixes a bug in "git codereview branchpoint", and therefore also commands like "git codereview pending", which was getting the branchpoint wrong for merges, with the effect that a merge showed too many pending CLs. This CL also fixes a bug in "git codereview change", which was formerly willing to run "git checkout" with a pending merge, which had the effect of flattening the merge mysteriously. Now it detects the merge and refuses to run. All of this should make merges easier and less error-prone as we use dev branches more often. With the earlier CL in this stack that allows working directly on local branches, this is now a great way to run a merge updating dev.regabi: git change dev.regabi git sync-branch (with appropriate aliases to avoid typing "codereview"). Fixes golang/go#26201. Change-Id: Ic24603123ca5135a72004309f5bb208ff149c9eb Reviewed-on: https://go-review.googlesource.com/c/review/+/279772 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'git-codereview/util_test.go')
-rw-r--r--git-codereview/util_test.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/git-codereview/util_test.go b/git-codereview/util_test.go
index b1b5534..a4f0b51 100644
--- a/git-codereview/util_test.go
+++ b/git-codereview/util_test.go
@@ -15,6 +15,8 @@ import (
"os/exec"
"path/filepath"
"reflect"
+ "regexp"
+ "runtime/debug"
"strings"
"sync"
"testing"
@@ -167,7 +169,12 @@ func newGitTest(t *testing.T) (gt *gitTest) {
trun(t, server, "git", "checkout", "main")
trun(t, server, "git", "checkout", "-b", name)
write(t, server+"/file."+name, "this is "+name, 0644)
- trun(t, server, "git", "add", "file."+name)
+ cfg := "branch: " + name + "\n"
+ if name == "dev.branch" {
+ cfg += "parent-branch: main\n"
+ }
+ write(t, server+"/codereview.cfg", cfg, 0644)
+ trun(t, server, "git", "add", "file."+name, "codereview.cfg")
trun(t, server, "git", "commit", "-m", "on "+name)
}
trun(t, server, "git", "checkout", "main")
@@ -330,7 +337,7 @@ func testMain(t *testing.T, args ...string) {
if died {
msg = "died"
} else {
- msg = fmt.Sprintf("panic: %v", err)
+ msg = fmt.Sprintf("panic: %v\n%s", err, debug.Stack())
}
t.Fatalf("%s\nstdout:\n%sstderr:\n%s", msg, testStdout, testStderr)
}
@@ -380,6 +387,16 @@ func testPrinted(t *testing.T, buf *bytes.Buffer, name string, messages ...strin
}
}
+func testHideRevHashes(t *testing.T) {
+ for _, b := range []*bytes.Buffer{testStdout, testStderr} {
+ out := b.Bytes()
+ out = regexp.MustCompile(`\b[0-9a-f]{7}\b`).ReplaceAllLiteral(out, []byte("REVHASH"))
+ out = regexp.MustCompile(`\b\d{4}-\d{2}-\d{2}\b`).ReplaceAllLiteral(out, []byte("DATE"))
+ b.Reset()
+ b.Write(out)
+ }
+}
+
func testPrintedStdout(t *testing.T, messages ...string) {
t.Helper()
testPrinted(t, testStdout, "stdout", messages...)