aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/util_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-01-07 21:14:22 -0500
committerRuss Cox <rsc@golang.org>2021-01-13 09:36:16 -0500
commit6244401143db649bfa09234e4b0e4db1b40b8ec3 (patch)
treec196f7ba683ef1920535bbc5bb2842266179cb61 /git-codereview/util_test.go
parentbc5a6b70306f5512d03ea7ddb2da996887092555 (diff)
downloadgo-x-review-1.0.0.tar.xz
git-codereview: add sync-branch -merge-back-to-parentv1.0.0
Dev branches come to an end. Making sync-branch help that process instead of forcing people to follow a playbook will help avoid mistakes. The flag name was chosen to be very unlikely to be used accidentally, and the commit subject and message both are distinct to make clear to reviewers what they are being asked to +2. The Merge List is also included in full and is likely to be quite large, yet another signal for everyone involved about the magnitude and weight of the change. Change-Id: I91cdda2b85cd3811711a339f4f3290fee109022e
Diffstat (limited to 'git-codereview/util_test.go')
-rw-r--r--git-codereview/util_test.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/git-codereview/util_test.go b/git-codereview/util_test.go
index a4f0b51..775b244 100644
--- a/git-codereview/util_test.go
+++ b/git-codereview/util_test.go
@@ -69,7 +69,7 @@ func (gt *gitTest) done() {
}
// doWork simulates commit 'n' touching 'file' in 'dir'
-func doWork(t *testing.T, n int, dir, file, changeid string) {
+func doWork(t *testing.T, n int, dir, file, changeid string, msg string) {
t.Helper()
write(t, dir+"/"+file, fmt.Sprintf("new content %d", n), 0644)
trun(t, dir, "git", "add", file)
@@ -77,8 +77,11 @@ func doWork(t *testing.T, n int, dir, file, changeid string) {
if n > 1 {
suffix = fmt.Sprintf(" #%d", n)
}
- msg := fmt.Sprintf("msg%s\n\nChange-Id: I%d%s\n", suffix, n, changeid)
- trun(t, dir, "git", "commit", "-m", msg)
+ if msg != "" {
+ msg += "\n\n"
+ }
+ cmsg := fmt.Sprintf("%smsg%s\n\nChange-Id: I%d%s\n", msg, suffix, n, changeid)
+ trun(t, dir, "git", "commit", "-m", cmsg)
}
func (gt *gitTest) work(t *testing.T) {
@@ -91,14 +94,14 @@ func (gt *gitTest) work(t *testing.T) {
// make local change on client
gt.nwork++
- doWork(t, gt.nwork, gt.client, "file", "23456789")
+ doWork(t, gt.nwork, gt.client, "file", "23456789", "")
}
func (gt *gitTest) workFile(t *testing.T, file string) {
t.Helper()
// make local change on client in the specific file
gt.nwork++
- doWork(t, gt.nwork, gt.client, file, "23456789")
+ doWork(t, gt.nwork, gt.client, file, "23456789", "")
}
func (gt *gitTest) serverWork(t *testing.T) {
@@ -108,15 +111,15 @@ func (gt *gitTest) serverWork(t *testing.T) {
// having gone through Gerrit and submitted with possibly
// different commit hashes but the same content.
gt.nworkServer++
- doWork(t, gt.nworkServer, gt.server, "file", "23456789")
+ doWork(t, gt.nworkServer, gt.server, "file", "23456789", "")
}
-func (gt *gitTest) serverWorkUnrelated(t *testing.T) {
+func (gt *gitTest) serverWorkUnrelated(t *testing.T, msg string) {
t.Helper()
// make unrelated change on server
// this makes history different on client and server
gt.nworkOther++
- doWork(t, gt.nworkOther, gt.server, "otherfile", "9999")
+ doWork(t, gt.nworkOther, gt.server, "otherfile", "9999", msg)
}
func newGitTest(t *testing.T) (gt *gitTest) {