Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
55c0777
Remove preview header mediaTypeStarringPreview = "application/vnd.git…
andygrunwald Oct 15, 2021
76e4ffe
Remove preview header mediaTypeMigrationsPreview = "application/vnd.g…
andygrunwald Oct 15, 2021
54c0280
Remove preview header mediaTypeDeploymentStatusPreview = "application…
andygrunwald Oct 15, 2021
4ccaf8f
Remove preview header mediaTypeExpandDeploymentStatusPreview = "appli…
andygrunwald Oct 15, 2021
b0c59ec
Remove preview header mediaTypeReactionsPreview = "application/vnd.gi…
andygrunwald Oct 15, 2021
23de7d5
Remove preview header mediaTypeTimelinePreview = "application/vnd.git…
andygrunwald Oct 15, 2021
3b201b4
Remove preview header mediaTypeProjectsPreview = "application/vnd.git…
andygrunwald Oct 15, 2021
636f509
Remove preview header mediaTypeCommitSearchPreview = "application/vnd…
andygrunwald Oct 15, 2021
fa084ef
Remove preview header mediaTypeBlockUsersPreview = "application/vnd.g…
andygrunwald Oct 15, 2021
474fe4c
Remove preview header mediaTypeTopicsPreview = "application/vnd.githu…
andygrunwald Oct 15, 2021
f8b5801
Remove preview header mediaTypeRequiredApprovingReviewsPreview = "app…
andygrunwald Oct 15, 2021
356bc63
Remove preview header mediaTypePreReceiveHooksPreview = "application/…
andygrunwald Oct 15, 2021
54a607c
Remove preview header mediaTypeSignaturePreview = "application/vnd.gi…
andygrunwald Oct 15, 2021
a1839e6
Remove preview header mediaTypeProjectCardDetailsPreview = "applicati…
andygrunwald Oct 15, 2021
119bfc8
Remove preview header mediaTypeInteractionRestrictionsPreview = "appl…
andygrunwald Oct 15, 2021
2c9d9ae
Remove preview header mediaTypeEnablePagesAPIPreview = "application/v…
andygrunwald Oct 15, 2021
2cc3088
Remove preview header mediaTypeRequiredVulnerabilityAlertsPreview = "…
andygrunwald Oct 15, 2021
5e50bbe
Remove preview header mediaTypeRequiredAutomatedSecurityFixesPreview …
andygrunwald Oct 15, 2021
8ccdbbf
Remove preview header mediaTypeUpdatePullRequestBranchPreview = "appl…
andygrunwald Oct 15, 2021
6df4565
Remove preview header mediaTypeListPullsOrBranchesForCommitPreview = …
andygrunwald Oct 15, 2021
2d19de1
Remove preview header mediaTypeMemberAllowedRepoCreationTypePreview =…
andygrunwald Oct 15, 2021
8260d02
Remove preview header mediaTypeRepositoryTemplatePreview = "applicati…
andygrunwald Oct 15, 2021
c9bae15
Remove preview header mediaTypeMultiLineCommentsPreview = "applicatio…
andygrunwald Oct 15, 2021
9d5d9ed
Remove preview header mediaTypeOAuthAppPreview = "application/vnd.git…
andygrunwald Oct 15, 2021
206432a
Remove preview header mediaTypeRepositoryVisibilityPreview = "applica…
andygrunwald Oct 15, 2021
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
8 changes: 0 additions & 8 deletions github/activity_star.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package github
import (
"context"
"fmt"
"strings"
)

// StarredRepository is returned by ListStarred.
Expand Down Expand Up @@ -38,9 +37,6 @@ func (s *ActivityService) ListStargazers(ctx context.Context, owner, repo string
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeStarringPreview)

var stargazers []*Stargazer
resp, err := s.client.Do(ctx, req, &stargazers)
if err != nil {
Expand Down Expand Up @@ -86,10 +82,6 @@ func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *Ac
return nil, nil, err
}

// TODO: remove custom Accept header when APIs fully launch
acceptHeaders := []string{mediaTypeStarringPreview, mediaTypeTopicsPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

var repos []*StarredRepository
resp, err := s.client.Do(ctx, req, &repos)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions github/activity_star_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"context"
"fmt"
"net/http"
"strings"
"testing"
"time"

Expand All @@ -22,7 +21,6 @@ func TestActivityService_ListStargazers(t *testing.T) {

mux.HandleFunc("/repos/o/r/stargazers", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeStarringPreview)
testFormValues(t, r, values{
"page": "2",
})
Expand Down Expand Up @@ -62,7 +60,6 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {

mux.HandleFunc("/user/starred", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", strings.Join([]string{mediaTypeStarringPreview, mediaTypeTopicsPreview}, ", "))
fmt.Fprint(w, `[{"starred_at":"2002-02-10T15:30:00Z","repo":{"id":1}}]`)
})

Expand Down Expand Up @@ -98,7 +95,6 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {

mux.HandleFunc("/users/u/starred", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", strings.Join([]string{mediaTypeStarringPreview, mediaTypeTopicsPreview}, ", "))
testFormValues(t, r, values{
"sort": "created",
"direction": "asc",
Expand Down
17 changes: 0 additions & 17 deletions github/apps_installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package github
import (
"context"
"fmt"
"strings"
)

// ListRepositories represents the response from the list repos endpoints.
Expand All @@ -31,14 +30,6 @@ 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,
mediaTypeRepositoryTemplatePreview,
}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

var r *ListRepositories

resp, err := s.client.Do(ctx, req, &r)
Expand All @@ -65,14 +56,6 @@ 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,
mediaTypeRepositoryTemplatePreview,
}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

var r *ListRepositories
resp, err := s.client.Do(ctx, req, &r)
if err != nil {
Expand Down
13 changes: 0 additions & 13 deletions github/apps_installation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"context"
"fmt"
"net/http"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
Expand All @@ -19,14 +18,8 @@ func TestAppsService_ListRepos(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{
mediaTypeTopicsPreview,
mediaTypeRepositoryVisibilityPreview,
mediaTypeRepositoryTemplatePreview,
}
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",
Expand Down Expand Up @@ -60,14 +53,8 @@ func TestAppsService_ListUserRepos(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{
mediaTypeTopicsPreview,
mediaTypeRepositoryVisibilityPreview,
mediaTypeRepositoryTemplatePreview,
}
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",
Expand Down
4 changes: 0 additions & 4 deletions github/authorizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", mediaTypeOAuthAppPreview)

a := new(Authorization)
resp, err := s.client.Do(ctx, req, a)
Expand Down Expand Up @@ -188,7 +187,6 @@ func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", mediaTypeOAuthAppPreview)

a := new(Authorization)
resp, err := s.client.Do(ctx, req, a)
Expand Down Expand Up @@ -217,7 +215,6 @@ func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToke
if err != nil {
return nil, err
}
req.Header.Set("Accept", mediaTypeOAuthAppPreview)

return s.client.Do(ctx, req, nil)
}
Expand All @@ -238,7 +235,6 @@ func (s *AuthorizationsService) DeleteGrant(ctx context.Context, clientID, acces
if err != nil {
return nil, err
}
req.Header.Set("Accept", mediaTypeOAuthAppPreview)

return s.client.Do(ctx, req, nil)
}
Expand Down
4 changes: 0 additions & 4 deletions github/authorizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func TestAuthorizationsService_Check(t *testing.T) {
mux.HandleFunc("/applications/id/token", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testBody(t, r, `{"access_token":"a"}`+"\n")
testHeader(t, r, "Accept", mediaTypeOAuthAppPreview)
fmt.Fprint(w, `{"id":1}`)
})

Expand Down Expand Up @@ -58,7 +57,6 @@ func TestAuthorizationsService_Reset(t *testing.T) {
mux.HandleFunc("/applications/id/token", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
testBody(t, r, `{"access_token":"a"}`+"\n")
testHeader(t, r, "Accept", mediaTypeOAuthAppPreview)
fmt.Fprint(w, `{"ID":1}`)
})

Expand Down Expand Up @@ -95,7 +93,6 @@ func TestAuthorizationsService_Revoke(t *testing.T) {
mux.HandleFunc("/applications/id/token", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testBody(t, r, `{"access_token":"a"}`+"\n")
testHeader(t, r, "Accept", mediaTypeOAuthAppPreview)
w.WriteHeader(http.StatusNoContent)
})

Expand Down Expand Up @@ -123,7 +120,6 @@ func TestDeleteGrant(t *testing.T) {
mux.HandleFunc("/applications/id/grant", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testBody(t, r, `{"access_token":"a"}`+"\n")
testHeader(t, r, "Accept", mediaTypeOAuthAppPreview)
})

ctx := context.Background()
Expand Down
75 changes: 0 additions & 75 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,84 +49,9 @@ const (

// Media Type values to access preview APIs

// https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/
mediaTypeStarringPreview = "application/vnd.github.v3.star+json"

// https://help.github.com/enterprise/2.4/admin/guides/migrations/exporting-the-github-com-organization-s-repositories/
mediaTypeMigrationsPreview = "application/vnd.github.wyandotte-preview+json"

// https://developer.github.com/changes/2016-04-06-deployment-and-deployment-status-enhancements/
mediaTypeDeploymentStatusPreview = "application/vnd.github.ant-man-preview+json"

// https://developer.github.com/changes/2018-10-16-deployments-environments-states-and-auto-inactive-updates/
mediaTypeExpandDeploymentStatusPreview = "application/vnd.github.flash-preview+json"

// https://developer.github.com/changes/2016-05-12-reactions-api-preview/
mediaTypeReactionsPreview = "application/vnd.github.squirrel-girl-preview"

// https://developer.github.com/changes/2016-05-23-timeline-preview-api/
mediaTypeTimelinePreview = "application/vnd.github.mockingbird-preview+json"

// https://developer.github.com/changes/2016-09-14-projects-api/
mediaTypeProjectsPreview = "application/vnd.github.inertia-preview+json"

// https://developer.github.com/changes/2017-01-05-commit-search-api/
mediaTypeCommitSearchPreview = "application/vnd.github.cloak-preview+json"

// https://developer.github.com/changes/2017-02-28-user-blocking-apis-and-webhook/
mediaTypeBlockUsersPreview = "application/vnd.github.giant-sentry-fist-preview+json"

// https://developer.github.com/changes/2017-05-23-coc-api/
mediaTypeCodesOfConductPreview = "application/vnd.github.scarlet-witch-preview+json"

// https://developer.github.com/changes/2017-07-17-update-topics-on-repositories/
mediaTypeTopicsPreview = "application/vnd.github.mercy-preview+json"

// https://developer.github.com/changes/2018-03-16-protected-branches-required-approving-reviews/
mediaTypeRequiredApprovingReviewsPreview = "application/vnd.github.luke-cage-preview+json"

// https://developer.github.com/enterprise/2.13/v3/repos/pre_receive_hooks/
mediaTypePreReceiveHooksPreview = "application/vnd.github.eye-scream-preview"

// https://developer.github.com/changes/2018-02-22-protected-branches-required-signatures/
mediaTypeSignaturePreview = "application/vnd.github.zzzax-preview+json"

// https://developer.github.com/changes/2018-09-05-project-card-events/
mediaTypeProjectCardDetailsPreview = "application/vnd.github.starfox-preview+json"

// https://developer.github.com/changes/2018-12-18-interactions-preview/
mediaTypeInteractionRestrictionsPreview = "application/vnd.github.sombra-preview+json"

// https://developer.github.com/changes/2019-03-14-enabling-disabling-pages/
mediaTypeEnablePagesAPIPreview = "application/vnd.github.switcheroo-preview+json"

// https://developer.github.com/changes/2019-04-24-vulnerability-alerts/
mediaTypeRequiredVulnerabilityAlertsPreview = "application/vnd.github.dorian-preview+json"

// https://developer.github.com/changes/2019-06-04-automated-security-fixes/
mediaTypeRequiredAutomatedSecurityFixesPreview = "application/vnd.github.london-preview+json"

// https://developer.github.com/changes/2019-05-29-update-branch-api/
mediaTypeUpdatePullRequestBranchPreview = "application/vnd.github.lydian-preview+json"

// https://developer.github.com/changes/2019-04-11-pulls-branches-for-commit/
mediaTypeListPullsOrBranchesForCommitPreview = "application/vnd.github.groot-preview+json"

// https://docs.github.com/en/free-pro-team@latest/rest/reference/previews/#repository-creation-permissions
mediaTypeMemberAllowedRepoCreationTypePreview = "application/vnd.github.surtur-preview+json"

// https://docs.github.com/en/free-pro-team@latest/rest/reference/previews/#create-and-use-repository-templates
mediaTypeRepositoryTemplatePreview = "application/vnd.github.baptiste-preview+json"

// https://developer.github.com/changes/2019-10-03-multi-line-comments/
mediaTypeMultiLineCommentsPreview = "application/vnd.github.comfort-fade-preview+json"

// https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/
mediaTypeOAuthAppPreview = "application/vnd.github.doctor-strange-preview+json"

// https://developer.github.com/changes/2019-12-03-internal-visibility-changes/
mediaTypeRepositoryVisibilityPreview = "application/vnd.github.nebula-preview+json"

// https://developer.github.com/changes/2018-12-10-content-attachments-api/
mediaTypeContentAttachmentsPreview = "application/vnd.github.corsair-preview+json"
)
Expand Down
9 changes: 0 additions & 9 deletions github/interactions_orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organiz
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)

organizationInteractions := new(InteractionRestriction)

resp, err := s.client.Do(ctx, req, organizationInteractions)
Expand Down Expand Up @@ -50,9 +47,6 @@ func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, orga
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)

organizationInteractions := new(InteractionRestriction)

resp, err := s.client.Do(ctx, req, organizationInteractions)
Expand All @@ -73,8 +67,5 @@ func (s *InteractionsService) RemoveRestrictionsFromOrg(ctx context.Context, org
return nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)

return s.client.Do(ctx, req, nil)
}
3 changes: 0 additions & 3 deletions github/interactions_orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func TestInteractionsService_GetRestrictionsForOrgs(t *testing.T) {

mux.HandleFunc("/orgs/o/interaction-limits", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview)
fmt.Fprint(w, `{"origin":"organization"}`)
})

Expand Down Expand Up @@ -62,7 +61,6 @@ func TestInteractionsService_UpdateRestrictionsForOrg(t *testing.T) {
json.NewDecoder(r.Body).Decode(v)

testMethod(t, r, "PUT")
testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview)
if !cmp.Equal(v, input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
Expand Down Expand Up @@ -101,7 +99,6 @@ func TestInteractionsService_RemoveRestrictionsFromOrg(t *testing.T) {

mux.HandleFunc("/orgs/o/interaction-limits", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview)
})

ctx := context.Background()
Expand Down
9 changes: 0 additions & 9 deletions github/interactions_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner,
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)

repositoryInteractions := new(InteractionRestriction)

resp, err := s.client.Do(ctx, req, repositoryInteractions)
Expand Down Expand Up @@ -50,9 +47,6 @@ func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, own
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)

repositoryInteractions := new(InteractionRestriction)

resp, err := s.client.Do(ctx, req, repositoryInteractions)
Expand All @@ -73,8 +67,5 @@ func (s *InteractionsService) RemoveRestrictionsFromRepo(ctx context.Context, ow
return nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)

return s.client.Do(ctx, req, nil)
}
3 changes: 0 additions & 3 deletions github/interactions_repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func TestInteractionsService_GetRestrictionsForRepo(t *testing.T) {

mux.HandleFunc("/repos/o/r/interaction-limits", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview)
fmt.Fprint(w, `{"origin":"repository"}`)
})

Expand Down Expand Up @@ -62,7 +61,6 @@ func TestInteractionsService_UpdateRestrictionsForRepo(t *testing.T) {
json.NewDecoder(r.Body).Decode(v)

testMethod(t, r, "PUT")
testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview)
if !cmp.Equal(v, input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
Expand Down Expand Up @@ -101,7 +99,6 @@ func TestInteractionsService_RemoveRestrictionsFromRepo(t *testing.T) {

mux.HandleFunc("/repos/o/r/interaction-limits", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview)
})

ctx := context.Background()
Expand Down
Loading