Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions github/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,9 @@ func (s *RepositoriesService) ListTags(owner string, repo string, opt *ListOptio

// Branch represents a repository branch
type Branch struct {
Name *string `json:"name,omitempty"`
Commit *Commit `json:"commit,omitempty"`
Protected *bool `json:"protected,omitempty"`
Name *string `json:"name,omitempty"`
Commit *RepositoryCommit `json:"commit,omitempty"`
Protected *bool `json:"protected,omitempty"`
}

// Protection represents a repository branch's protection.
Expand Down
13 changes: 9 additions & 4 deletions github/repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func TestRepositoriesService_ListBranches(t *testing.T) {
t.Errorf("Repositories.ListBranches returned error: %v", err)
}

want := []*Branch{{Name: String("master"), Commit: &Commit{SHA: String("a57781"), URL: String("https://github.com/api/repos/o/r/commits/a57781")}}}
want := []*Branch{{Name: String("master"), Commit: &RepositoryCommit{SHA: String("a57781"), URL: String("https://github.com/api/repos/o/r/commits/a57781")}}}
if !reflect.DeepEqual(branches, want) {
t.Errorf("Repositories.ListBranches returned %+v, want %+v", branches, want)
}
Expand All @@ -447,7 +447,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) {
mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
fmt.Fprint(w, `{"name":"n", "commit":{"sha":"s"}, "protected":true}`)
fmt.Fprint(w, `{"name":"n", "commit":{"sha":"s","commit":{"message":"m"}}, "protected":true}`)
})

branch, _, err := client.Repositories.GetBranch("o", "r", "b")
Expand All @@ -456,8 +456,13 @@ func TestRepositoriesService_GetBranch(t *testing.T) {
}

want := &Branch{
Name: String("n"),
Commit: &Commit{SHA: String("s")},
Name: String("n"),
Commit: &RepositoryCommit{
SHA: String("s"),
Commit: &Commit{
Message: String("m"),
},
},
Protected: Bool(true),
}

Expand Down