Skip to content

Commit cf71803

Browse files
authored
Merge branch 'trunk' into gist-edit-large-file
2 parents 8e963a8 + 119085c commit cf71803

46 files changed

Lines changed: 1949 additions & 727 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ jobs:
3434
go-version-file: "go.mod"
3535

3636
- name: Initialize CodeQL
37-
uses: github/codeql-action/init@v3
37+
uses: github/codeql-action/init@v4
3838
with:
3939
languages: ${{ matrix.language }}
4040
queries: security-and-quality
4141

4242
- name: Perform CodeQL Analysis
43-
uses: github/codeql-action/analyze@v3
43+
uses: github/codeql-action/analyze@v4
4444
with:
4545
category: "/language:${{ matrix.language }}"
4646
upload: false
@@ -56,7 +56,7 @@ jobs:
5656
output: sarif-results/${{ matrix.language }}.sarif
5757

5858
- name: Upload filtered SARIF
59-
uses: github/codeql-action/upload-sarif@v3
59+
uses: github/codeql-action/upload-sarif@v4
6060
with:
6161
sarif_file: sarif-results/${{ matrix.language }}.sarif
6262
category: "/language:${{ matrix.language }}"

.github/workflows/deployment.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
with:
5151
go-version-file: 'go.mod'
5252
- name: Install GoReleaser
53-
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552
53+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a
5454
with:
5555
version: "~1.17.1"
5656
install-only: true
@@ -62,7 +62,7 @@ jobs:
6262
run: |
6363
go run ./cmd/gen-docs --website --doc-path dist/manual
6464
tar -czvf dist/manual.tar.gz -C dist -- manual
65-
- uses: actions/upload-artifact@v4
65+
- uses: actions/upload-artifact@v5
6666
with:
6767
name: linux
6868
if-no-files-found: error
@@ -103,7 +103,7 @@ jobs:
103103
security set-key-partition-list -S "apple-tool:,apple:,codesign:" -s -k "$keychain_password" "$keychain"
104104
rm "$RUNNER_TEMP/cert.p12"
105105
- name: Install GoReleaser
106-
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552
106+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a
107107
with:
108108
version: "~1.17.1"
109109
install-only: true
@@ -134,7 +134,7 @@ jobs:
134134
run: |
135135
shopt -s failglob
136136
script/pkgmacos "$TAG_NAME"
137-
- uses: actions/upload-artifact@v4
137+
- uses: actions/upload-artifact@v5
138138
with:
139139
name: macos
140140
if-no-files-found: error
@@ -157,7 +157,7 @@ jobs:
157157
with:
158158
go-version-file: 'go.mod'
159159
- name: Install GoReleaser
160-
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552
160+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a
161161
with:
162162
version: "~1.17.1"
163163
install-only: true
@@ -238,7 +238,7 @@ jobs:
238238
Get-ChildItem -Path .\dist -Filter *.msi | ForEach-Object {
239239
.\script\sign.ps1 $_.FullName
240240
}
241-
- uses: actions/upload-artifact@v4
241+
- uses: actions/upload-artifact@v5
242242
with:
243243
name: windows
244244
if-no-files-found: error
@@ -256,7 +256,7 @@ jobs:
256256
- name: Checkout cli/cli
257257
uses: actions/checkout@v5
258258
- name: Merge built artifacts
259-
uses: actions/download-artifact@v5
259+
uses: actions/download-artifact@v6
260260
- name: Checkout documentation site
261261
uses: actions/checkout@v5
262262
with:
@@ -309,7 +309,7 @@ jobs:
309309
rpmsign --addsign dist/*.rpm
310310
- name: Attest release artifacts
311311
if: inputs.environment == 'production'
312-
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
312+
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
313313
with:
314314
subject-path: "dist/gh_*"
315315
- name: Run createrepo
@@ -384,7 +384,7 @@ jobs:
384384
git diff --name-status @{upstream}..
385385
fi
386386
- name: Bump homebrew-core formula
387-
uses: mislav/bump-homebrew-formula-action@8e2baa47daaa8db10fcdeb04105dfa6850eb0d68
387+
uses: mislav/bump-homebrew-formula-action@56a283fa15557e9abaa4bdb63b8212abc68e655c
388388
if: inputs.environment == 'production' && !contains(inputs.tag_name, '-')
389389
with:
390390
formula-name: gh

.github/workflows/govulncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
go run golang.org/x/vuln/cmd/govulncheck@d1f380186385b4f64e00313f31743df8e4b89a77 -format sarif ./... > gh.sarif
2525
2626
- name: Upload SARIF report
27-
uses: github/codeql-action/upload-sarif@9b02dc2f60288b463e7a66e39c78829b62780db7 # 2.22.1
27+
uses: github/codeql-action/upload-sarif@v4
2828
with:
2929
sarif_file: gh.sarif

.github/workflows/homebrew-bump.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Bump homebrew-core formula
20-
uses: mislav/bump-homebrew-formula-action@8e2baa47daaa8db10fcdeb04105dfa6850eb0d68
20+
uses: mislav/bump-homebrew-formula-action@56a283fa15557e9abaa4bdb63b8212abc68e655c
2121
if: inputs.environment == 'production' && !contains(inputs.tag_name, '-')
2222
with:
2323
formula-name: gh

api/http_client.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@ type tokenGetter interface {
1717
}
1818

1919
type HTTPClientOptions struct {
20-
AppVersion string
21-
CacheTTL time.Duration
22-
Config tokenGetter
23-
EnableCache bool
24-
Log io.Writer
25-
LogColorize bool
26-
LogVerboseHTTP bool
20+
AppVersion string
21+
CacheTTL time.Duration
22+
Config tokenGetter
23+
EnableCache bool
24+
Log io.Writer
25+
LogColorize bool
26+
LogVerboseHTTP bool
27+
SkipDefaultHeaders bool
2728
}
2829

2930
func NewHTTPClient(opts HTTPClientOptions) (*http.Client, error) {
3031
// Provide invalid host, and token values so gh.HTTPClient will not automatically resolve them.
3132
// The real host and token are inserted at request time.
3233
clientOpts := ghAPI.ClientOptions{
33-
Host: "none",
34-
AuthToken: "none",
35-
LogIgnoreEnv: true,
34+
Host: "none",
35+
AuthToken: "none",
36+
LogIgnoreEnv: true,
37+
SkipDefaultHeaders: opts.SkipDefaultHeaders,
3638
}
3739

3840
debugEnabled, debugValue := utils.IsDebugEnabled()

api/http_client_test.go

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ import (
1818

1919
func TestNewHTTPClient(t *testing.T) {
2020
type args struct {
21-
config tokenGetter
22-
appVersion string
23-
logVerboseHTTP bool
21+
config tokenGetter
22+
appVersion string
23+
logVerboseHTTP bool
24+
skipDefaultHeaders bool
2425
}
2526
tests := []struct {
2627
name string
2728
args args
2829
host string
29-
wantHeader map[string]string
30+
wantHeader map[string][]string
3031
wantStderr string
3132
}{
3233
{
@@ -37,10 +38,10 @@ func TestNewHTTPClient(t *testing.T) {
3738
logVerboseHTTP: false,
3839
},
3940
host: "github.com",
40-
wantHeader: map[string]string{
41-
"authorization": "token MYTOKEN",
42-
"user-agent": "GitHub CLI v1.2.3",
43-
"accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview",
41+
wantHeader: map[string][]string{
42+
"authorization": {"token MYTOKEN"},
43+
"user-agent": {"GitHub CLI v1.2.3"},
44+
"accept": {"application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview"},
4445
},
4546
wantStderr: "",
4647
},
@@ -51,10 +52,10 @@ func TestNewHTTPClient(t *testing.T) {
5152
appVersion: "v1.2.3",
5253
},
5354
host: "example.com",
54-
wantHeader: map[string]string{
55-
"authorization": "token GHETOKEN",
56-
"user-agent": "GitHub CLI v1.2.3",
57-
"accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview",
55+
wantHeader: map[string][]string{
56+
"authorization": {"token GHETOKEN"},
57+
"user-agent": {"GitHub CLI v1.2.3"},
58+
"accept": {"application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview"},
5859
},
5960
wantStderr: "",
6061
},
@@ -66,10 +67,10 @@ func TestNewHTTPClient(t *testing.T) {
6667
logVerboseHTTP: false,
6768
},
6869
host: "github.com",
69-
wantHeader: map[string]string{
70-
"authorization": "",
71-
"user-agent": "GitHub CLI v1.2.3",
72-
"accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview",
70+
wantHeader: map[string][]string{
71+
"authorization": nil, // should not be set
72+
"user-agent": {"GitHub CLI v1.2.3"},
73+
"accept": {"application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview"},
7374
},
7475
wantStderr: "",
7576
},
@@ -81,10 +82,10 @@ func TestNewHTTPClient(t *testing.T) {
8182
logVerboseHTTP: false,
8283
},
8384
host: "example.com",
84-
wantHeader: map[string]string{
85-
"authorization": "",
86-
"user-agent": "GitHub CLI v1.2.3",
87-
"accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview",
85+
wantHeader: map[string][]string{
86+
"authorization": nil, // should not be set
87+
"user-agent": {"GitHub CLI v1.2.3"},
88+
"accept": {"application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview"},
8889
},
8990
wantStderr: "",
9091
},
@@ -96,10 +97,10 @@ func TestNewHTTPClient(t *testing.T) {
9697
logVerboseHTTP: true,
9798
},
9899
host: "github.com",
99-
wantHeader: map[string]string{
100-
"authorization": "token MYTOKEN",
101-
"user-agent": "GitHub CLI v1.2.3",
102-
"accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview",
100+
wantHeader: map[string][]string{
101+
"authorization": {"token MYTOKEN"},
102+
"user-agent": {"GitHub CLI v1.2.3"},
103+
"accept": {"application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview"},
103104
},
104105
wantStderr: heredoc.Doc(`
105106
* Request at <time>
@@ -115,6 +116,34 @@ func TestNewHTTPClient(t *testing.T) {
115116
< HTTP/1.1 204 No Content
116117
< Date: <time>
117118
119+
* Request took <duration>
120+
`),
121+
},
122+
{
123+
name: "respect skip default headers option",
124+
args: args{
125+
appVersion: "v1.2.3",
126+
logVerboseHTTP: true,
127+
skipDefaultHeaders: true,
128+
},
129+
host: "github.com",
130+
wantHeader: map[string][]string{
131+
"accept": nil,
132+
"authorization": nil,
133+
"content-type": nil,
134+
"user-agent": {"GitHub CLI v1.2.3"},
135+
},
136+
wantStderr: heredoc.Doc(`
137+
* Request at <time>
138+
* Request to http://<host>:<port>
139+
> GET / HTTP/1.1
140+
> Host: github.com
141+
> Time-Zone: <timezone>
142+
> User-Agent: GitHub CLI v1.2.3
143+
144+
< HTTP/1.1 204 No Content
145+
< Date: <time>
146+
118147
* Request took <duration>
119148
`),
120149
},
@@ -131,10 +160,11 @@ func TestNewHTTPClient(t *testing.T) {
131160
t.Run(tt.name, func(t *testing.T) {
132161
ios, _, _, stderr := iostreams.Test()
133162
client, err := NewHTTPClient(HTTPClientOptions{
134-
AppVersion: tt.args.appVersion,
135-
Config: tt.args.config,
136-
Log: ios.ErrOut,
137-
LogVerboseHTTP: tt.args.logVerboseHTTP,
163+
AppVersion: tt.args.appVersion,
164+
Config: tt.args.config,
165+
Log: ios.ErrOut,
166+
LogVerboseHTTP: tt.args.logVerboseHTTP,
167+
SkipDefaultHeaders: tt.args.skipDefaultHeaders,
138168
})
139169
require.NoError(t, err)
140170

@@ -148,7 +178,7 @@ func TestNewHTTPClient(t *testing.T) {
148178
require.NoError(t, err)
149179

150180
for name, value := range tt.wantHeader {
151-
assert.Equal(t, value, gotReq.Header.Get(name), name)
181+
assert.Equal(t, value, gotReq.Header.Values(name), name)
152182
}
153183

154184
assert.Equal(t, 204, res.StatusCode)

0 commit comments

Comments
 (0)