git-codereview: fix missing upstream detection
With git 2.4.3, the current tests fail (and it breaks in real use):
$ go test
git rev-parse --abbrev-ref newbranch@{u}
fatal: no upstream configured for branch 'newbranch'
git-codereview: exit status 128
exit status 1
FAIL golang.org/x/review/git-codereview 0.361s
$
The message changed from "No" to "no". Fix detection.
Change-Id: I814a7cec612fc12496ef89ccfd80fb70c09d4e46
Reviewed-on: https://go-review.googlesource.com/11172
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
diff --git a/git-codereview/branch.go b/git-codereview/branch.go
index cabe7f6..5eacb10 100644
--- a/git-codereview/branch.go
+++ b/git-codereview/branch.go
@@ -72,7 +72,9 @@
b.originBranch = string(bytes.TrimSpace(out))
return b.originBranch
}
- if strings.Contains(string(out), "No upstream configured") {
+
+ // Have seen both "No upstream configured" and "no upstream configured".
+ if strings.Contains(string(out), "upstream configured") {
// Assume branch was created before we set upstream correctly.
b.originBranch = "origin/master"
return b.originBranch