From b53505978e90bf5b74d0464889af9823a162922a Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Sun, 21 Feb 2021 10:08:29 +0100 Subject: [PATCH] Apps.ListRepos/Apps.ListUserRepos: Add mercy-preview + nebula-preview headers * mercy-preview: For receiving repository topics * nebula-preview: For visibility information --- github/apps_installation.go | 9 +++++++++ github/apps_installation_test.go | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/github/apps_installation.go b/github/apps_installation.go index b4ac5eefefd..501d8006ba0 100644 --- a/github/apps_installation.go +++ b/github/apps_installation.go @@ -8,6 +8,7 @@ package github import ( "context" "fmt" + "strings" ) // ListRepositories represents the response from the list repos endpoints. @@ -30,6 +31,10 @@ func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRe return nil, nil, err } + // TODO: remove custom Accept headers when APIs fully launch. + acceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview} + req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + var r *ListRepositories resp, err := s.client.Do(ctx, req, &r) @@ -56,6 +61,10 @@ func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOpt return nil, nil, err } + // TODO: remove custom Accept headers when APIs fully launch. + acceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview} + req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) + var r *ListRepositories resp, err := s.client.Do(ctx, req, &r) if err != nil { diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index a73498c6dad..5e8a18deb09 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -10,6 +10,7 @@ import ( "fmt" "net/http" "reflect" + "strings" "testing" ) @@ -17,8 +18,10 @@ func TestAppsService_ListRepos(t *testing.T) { client, mux, _, teardown := setup() defer teardown() + wantAcceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/installation/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) testFormValues(t, r, values{ "page": "1", "per_page": "2", @@ -52,8 +55,10 @@ func TestAppsService_ListUserRepos(t *testing.T) { client, mux, _, teardown := setup() defer teardown() + wantAcceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview} mux.HandleFunc("/user/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) testFormValues(t, r, values{ "page": "1", "per_page": "2",