Update "Accept" header for github.com requests

The `antiope-preview` has graduated in github.com and no longer needs
activating. However, we still need it for GHES requests.
This commit is contained in:
Mislav Marohnić 2021-06-08 19:25:40 +02:00
parent 8a221bb766
commit 3a55c26000
2 changed files with 5 additions and 8 deletions

View file

@ -88,13 +88,10 @@ func NewHTTPClient(io *iostreams.IOStreams, cfg configGetter, appVersion string,
if setAccept {
opts = append(opts,
api.AddHeaderFunc("Accept", func(req *http.Request) (string, error) {
// antiope-preview: Checks
accept := "application/vnd.github.antiope-preview+json"
// introduced for #2952: pr branch up to date status
accept += ", application/vnd.github.merge-info-preview+json"
accept := "application/vnd.github.merge-info-preview+json" // PullRequest.mergeStateStatus
if ghinstance.IsEnterprise(getHost(req)) {
// shadow-cat-preview: Draft pull requests
accept += ", application/vnd.github.shadow-cat-preview"
accept += ", application/vnd.github.antiope-preview" // Commit.statusCheckRollup
accept += ", application/vnd.github.shadow-cat-preview" // PullRequest.isDraft
}
return accept, nil
}),

View file

@ -39,7 +39,7 @@ func TestNewHTTPClient(t *testing.T) {
wantHeader: map[string]string{
"authorization": "token MYTOKEN",
"user-agent": "GitHub CLI v1.2.3",
"accept": "application/vnd.github.antiope-preview+json, application/vnd.github.merge-info-preview+json",
"accept": "application/vnd.github.merge-info-preview+json",
},
wantStderr: "",
},
@ -97,7 +97,7 @@ func TestNewHTTPClient(t *testing.T) {
wantHeader: map[string]string{
"authorization": "token GHETOKEN",
"user-agent": "GitHub CLI v1.2.3",
"accept": "application/vnd.github.antiope-preview+json, application/vnd.github.merge-info-preview+json, application/vnd.github.shadow-cat-preview",
"accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.antiope-preview, application/vnd.github.shadow-cat-preview",
},
wantStderr: "",
},