Skip to content

Commit 6cd5360

Browse files
isquagmlewis
authored andcommitted
Fix GetBranch response
Closes google#490. Change-Id: Ie12aca585fe07cb572b347ef3b8f42c26b229808
1 parent 963c812 commit 6cd5360

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

github/repos.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ func (s *RepositoriesService) ListTags(owner string, repo string, opt *ListOptio
501501

502502
// Branch represents a repository branch
503503
type Branch struct {
504-
Name *string `json:"name,omitempty"`
505-
Commit *Commit `json:"commit,omitempty"`
506-
Protected *bool `json:"protected,omitempty"`
504+
Name *string `json:"name,omitempty"`
505+
Commit *RepositoryCommit `json:"commit,omitempty"`
506+
Protected *bool `json:"protected,omitempty"`
507507
}
508508

509509
// Protection represents a repository branch's protection.

github/repos_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ func TestRepositoriesService_ListBranches(t *testing.T) {
434434
t.Errorf("Repositories.ListBranches returned error: %v", err)
435435
}
436436

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

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

458458
want := &Branch{
459-
Name: String("n"),
460-
Commit: &Commit{SHA: String("s")},
459+
Name: String("n"),
460+
Commit: &RepositoryCommit{
461+
SHA: String("s"),
462+
Commit: &Commit{
463+
Message: String("m"),
464+
},
465+
},
461466
Protected: Bool(true),
462467
}
463468

0 commit comments

Comments
 (0)