git-codereview: avoid Gerrit timeout for missing Change-Id during pending If a commit is missing a Change-Id line, pending queries https://go-review.googlesource.com/a/changes/go~master~?o=DETAILED_LABELS&o=CURRENT_REVISION&o=MESSAGES&o=DETAILED_ACCOUNTS (that's go~master~CHANGEID?... with CHANGEID=""), which must cause Gerrit to iterate over all possible CLs or something like that, because it takes forever. Don't bother: if the commit we care about has no Change-Id, it is by definition not on the server at all. This makes 'git pending' not just hang when you have a commit without a Change-Id. Change-Id: I548a51b4190db723538af35ea6a14169861d6bc3 Reviewed-on: https://go-review.googlesource.com/67570 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
diff --git a/git-codereview/branch.go b/git-codereview/branch.go index 5d47dc9..13193ff 100644 --- a/git-codereview/branch.go +++ b/git-codereview/branch.go
@@ -307,6 +307,9 @@ if !b.HasPendingCommit() { return nil, fmt.Errorf("no changes pending") } + if c.ChangeID == "" { + return nil, fmt.Errorf("missing Change-Id") + } id := fullChangeID(b, c) for i, x := range extra { if i == 0 {