From c93db92a2c811019047ca1c993225f3089955170 Mon Sep 17 00:00:00 2001 From: isqua Date: Sat, 10 Dec 2016 23:21:43 +0300 Subject: [PATCH 1/2] Fix GetBranch response --- github/repos.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/repos.go b/github/repos.go index 3df0b69aa49..040cd31e006 100644 --- a/github/repos.go +++ b/github/repos.go @@ -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. From dd945dce09ae81754585d9662517b7c7a521f90f Mon Sep 17 00:00:00 2001 From: isqua Date: Sat, 10 Dec 2016 23:27:44 +0300 Subject: [PATCH 2/2] Fix GetBranch response; Tests --- github/repos_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/github/repos_test.go b/github/repos_test.go index 6da0684f22e..20598d03fec 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -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://api.github.com/repos/o/r/commits/a57781")}}} + want := []*Branch{{Name: String("master"), Commit: &RepositoryCommit{SHA: String("a57781"), URL: String("https://api.github.com/repos/o/r/commits/a57781")}}} if !reflect.DeepEqual(branches, want) { t.Errorf("Repositories.ListBranches returned %+v, want %+v", branches, want) } @@ -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") @@ -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), }