maintner: add GerritCL.CommitAtVersion method

Previous versions were available via GerritProject.remote, but that
symbol is not exported and can't be used by callers of this package.

Update test for go-github API change in google/go-github#816, so the
tests can pass locally. Since go-github isn't vendored, it's understood
that the latest upstream version is targeted.

Change-Id: Ib4b78abacb19d73f95df2215b4a248a24376ae10
Reviewed-on: https://go-review.googlesource.com/95136
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/maintner/gerrit.go b/maintner/gerrit.go
index 7541938..edee678 100644
--- a/maintner/gerrit.go
+++ b/maintner/gerrit.go
@@ -259,7 +259,7 @@
 	Version int32
 
 	// Commit is the git commit of the latest version of this CL.
-	// Previous versions are available via GerritProject.remote.
+	// Previous versions are available via CommitAtVersion.
 	Commit *GitCommit
 
 	// branch is a cache of the latest "Branch: " value seen from
@@ -463,6 +463,19 @@
 	return cl.Commit.Msg
 }
 
+// CommitAtVersion returns the git commit of the specifid version of this CL.
+// It returns nil if version is not in the range [1, cl.Version].
+func (cl *GerritCL) CommitAtVersion(version int32) *GitCommit {
+	if version < 1 || version > cl.Version {
+		return nil
+	}
+	hash, ok := cl.Project.remote[gerritCLVersion{CLNumber: cl.Number, Version: version}]
+	if !ok {
+		return nil
+	}
+	return cl.Project.commit[hash]
+}
+
 func (cl *GerritCL) firstMetaCommit() *GitCommit {
 	m := cl.Meta
 	for m != nil && len(m.Parents) > 0 {
diff --git a/maintner/maintner_test.go b/maintner/maintner_test.go
index 9c66333..d51c441 100644
--- a/maintner/maintner_test.go
+++ b/maintner/maintner_test.go
@@ -162,7 +162,7 @@
 
 func TestNewAssigneesHandlesNil(t *testing.T) {
 	users := []*github.User{
-		&github.User{Login: github.String("foo"), ID: github.Int(3)},
+		&github.User{Login: github.String("foo"), ID: github.Int64(3)},
 	}
 	got := newAssignees(nil, users)
 	want := []*maintpb.GithubUser{&maintpb.GithubUser{
@@ -202,7 +202,7 @@
 
 	mutation := gr.newMutationFromIssue(issue, &github.Issue{
 		Number:    github.Int(3),
-		Assignees: []*github.User{&github.User{ID: github.Int(int(u2.ID))}},
+		Assignees: []*github.User{&github.User{ID: github.Int64(u2.ID)}},
 	})
 	c.addMutation(mutation)
 	gi := gr.issues[3]