diff --git a/github/pulls.go b/github/pulls.go index 017da75..307562d 100644 --- a/github/pulls.go +++ b/github/pulls.go @@ -169,7 +169,7 @@ func (s *PullRequestsService) Edit(owner string, repo string, number int, pull * // ListCommits lists the commits in a pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request -func (s *PullRequestsService) ListCommits(owner string, repo string, number int, opt *ListOptions) ([]Commit, *Response, error) { +func (s *PullRequestsService) ListCommits(owner string, repo string, number int, opt *ListOptions) ([]RepositoryCommit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/commits", owner, repo, number) u, err := addOptions(u, opt) if err != nil { @@ -181,7 +181,7 @@ func (s *PullRequestsService) ListCommits(owner string, repo string, number int, return nil, nil, err } - commits := new([]Commit) + commits := new([]RepositoryCommit) resp, err := s.client.Do(req, commits) if err != nil { return nil, resp, err diff --git a/github/pulls_test.go b/github/pulls_test.go index 9307c4e..545c905 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -205,8 +205,8 @@ func TestPullRequestsService_ListCommits(t *testing.T) { t.Errorf("PullRequests.ListCommits returned error: %v", err) } - want := []Commit{ - Commit{ + want := []RepositoryCommit{ + { SHA: String("3"), Parents: []Commit{ Commit{ @@ -214,7 +214,7 @@ func TestPullRequestsService_ListCommits(t *testing.T) { }, }, }, - Commit{ + { SHA: String("2"), Parents: []Commit{ Commit{ diff --git a/tests/integration/pulls_test.go b/tests/integration/pulls_test.go new file mode 100644 index 0000000..50a3221 --- /dev/null +++ b/tests/integration/pulls_test.go @@ -0,0 +1,23 @@ +// Copyright 2014 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package tests + +import "testing" + +func TestPullRequests_ListCommits(t *testing.T) { + commits, _, err := client.PullRequests.ListCommits("google", "go-github", 2, nil) + if err != nil { + t.Fatalf("PullRequests.ListCommits() returned error: %v", err) + } + + if got, want := len(commits), 3; got != want { + t.Fatalf("PullRequests.ListCommits() returned %d commits, want %d", got, want) + } + + if got, want := *commits[0].Author.Login, "sqs"; got != want { + t.Fatalf("PullRequests.ListCommits()[0].Author.Login returned %v, want %v", got, want) + } +}