X Tutup
Skip to content

Commit 78067e0

Browse files
committed
Merge branch 'trunk' into feature/gpg-key
2 parents 7e920a3 + d7f7a98 commit 78067e0

File tree

318 files changed

+9665
-3071
lines changed

Some content is hidden

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

318 files changed

+9665
-3071
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ Please avoid:
2323
## Building the project
2424

2525
Prerequisites:
26-
- Go 1.13+ for building the binary
27-
- Go 1.15+ for running the test suite
26+
- Go 1.16+
2827

2928
Build with:
3029
* Unix-like systems: `make`

.github/workflows/codeql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
uses: github/codeql-action/init@v1
1919
with:
2020
languages: go
21+
queries: security-and-quality
2122

2223
- name: Perform CodeQL Analysis
2324
uses: github/codeql-action/analyze@v1

.github/workflows/go.yml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
runs-on: ${{ matrix.os }}
1010

1111
steps:
12-
- name: Set up Go 1.15
12+
- name: Set up Go 1.16
1313
uses: actions/setup-go@v2
1414
with:
15-
go-version: 1.15
15+
go-version: 1.16
1616

1717
- name: Check out code
1818
uses: actions/checkout@v2
@@ -25,20 +25,3 @@ jobs:
2525

2626
- name: Build
2727
run: go build -v ./cmd/gh
28-
29-
build-minimum:
30-
runs-on: ubuntu-latest
31-
32-
steps:
33-
- name: Set up Go 1.13
34-
uses: actions/setup-go@v2
35-
with:
36-
go-version: 1.13
37-
38-
- name: Check out code
39-
uses: actions/checkout@v2
40-
41-
- name: Build
42-
env:
43-
CGO_ENABLED: '0'
44-
run: go build -v ./cmd/gh

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- name: Set up Go 1.15
19+
- name: Set up Go 1.16
2020
uses: actions/setup-go@v2
2121
with:
22-
go-version: 1.15
22+
go-version: 1.16
2323

2424
- name: Check out code
2525
uses: actions/checkout@v2

.github/workflows/releases.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v2
14-
- name: Set up Go 1.15
14+
- name: Set up Go 1.16
1515
uses: actions/setup-go@v2
1616
with:
17-
go-version: 1.15
17+
go-version: 1.16
1818
- name: Generate changelog
1919
run: |
2020
echo "GORELEASER_CURRENT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
@@ -23,7 +23,7 @@ jobs:
2323
- name: Run GoReleaser
2424
uses: goreleaser/goreleaser-action@v2
2525
with:
26-
version: latest
26+
version: v0.174.1
2727
args: release --release-notes=CHANGELOG.md
2828
env:
2929
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -33,7 +33,7 @@ jobs:
3333
repository: github/cli.github.com
3434
path: site
3535
fetch-depth: 0
36-
token: ${{secrets.SITE_GITHUB_TOKEN}}
36+
ssh-key: ${{secrets.SITE_SSH_KEY}}
3737
- name: Update site man pages
3838
env:
3939
GIT_COMMITTER_NAME: cli automation
@@ -197,3 +197,18 @@ jobs:
197197
GIT_AUTHOR_NAME: cli automation
198198
GIT_COMMITTER_EMAIL: noreply@github.com
199199
GIT_AUTHOR_EMAIL: noreply@github.com
200+
- name: Bump Winget manifest
201+
shell: pwsh
202+
env:
203+
WINGETCREATE_VERSION: v0.2.0.29-preview
204+
GITHUB_TOKEN: ${{ secrets.UPLOAD_GITHUB_TOKEN }}
205+
run: |
206+
$tagname = $env:GITHUB_REF.Replace("refs/tags/", "")
207+
$version = $tagname.Replace("v", "")
208+
$url = "https://github.com/cli/cli/releases/download/${tagname}/gh_${version}_windows_amd64.msi"
209+
iwr https://github.com/microsoft/winget-create/releases/download/${env:WINGETCREATE_VERSION}/wingetcreate.exe -OutFile wingetcreate.exe
210+
211+
.\wingetcreate.exe update GitHub.cli --url $url --version $version
212+
if ($version -notmatch "-") {
213+
.\wingetcreate.exe submit .\manifests\g\GitHub\cli\${version}\ --token $env:GITHUB_TOKEN
214+
}

.goreleaser.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ builds:
1515
binary: bin/gh
1616
main: ./cmd/gh
1717
ldflags:
18-
- -s -w -X github.com/cli/cli/internal/build.Version={{.Version}} -X github.com/cli/cli/internal/build.Date={{time "2006-01-02"}}
18+
- -s -w -X github.com/cli/cli/v2/internal/build.Version={{.Version}} -X github.com/cli/cli/v2/internal/build.Date={{time "2006-01-02"}}
1919
- -X main.updaterEnabled=cli/cli
2020
id: macos
2121
goos: [darwin]
@@ -57,12 +57,13 @@ nfpms:
5757
- license: MIT
5858
maintainer: GitHub
5959
homepage: https://github.com/cli/cli
60-
bindir: /usr
60+
bindir: /usr/bin
6161
dependencies:
6262
- git
6363
description: GitHub’s official command line tool.
6464
formats:
6565
- deb
6666
- rpm
67-
files:
68-
"./share/man/man1/gh*.1": "/usr/share/man/man1"
67+
contents:
68+
- src: "./share/man/man1/gh*.1"
69+
dst: "/usr/share/man/man1"

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ GitHub CLI is available for repositories hosted on GitHub.com and GitHub Enterpr
1414

1515
If anything feels off, or if you feel that some functionality is missing, please check out the [contributing page][contributing]. There you will find instructions for sharing your feedback, building the tool locally, and submitting pull requests to the project.
1616

17-
1817
<!-- this anchor is linked to from elsewhere, so avoid renaming it -->
1918
## Installation
2019

2120
### macOS
2221

23-
`gh` is available via [Homebrew][], [MacPorts][], and as a downloadable binary from the [releases page][].
22+
`gh` is available via [Homebrew][], [MacPorts][], [Conda][], and as a downloadable binary from the [releases page][].
2423

2524
#### Homebrew
2625

@@ -34,16 +33,23 @@ If anything feels off, or if you feel that some functionality is missing, please
3433
| ---------------------- | ---------------------------------------------- |
3534
| `sudo port install gh` | `sudo port selfupdate && sudo port upgrade gh` |
3635

37-
### Linux
36+
#### Conda
3837

39-
`gh` is available via [Homebrew](#homebrew), and as downloadable binaries from the [releases page][].
38+
| Install: | Upgrade: |
39+
|------------------------------------------|-----------------------------------------|
40+
| `conda install gh --channel conda-forge` | `conda update gh --channel conda-forge` |
4041

41-
For more information and distro-specific instructions, see the [Linux installation docs](./docs/install_linux.md).
42+
Additional Conda installation options available on the [gh-feedstock page](https://github.com/conda-forge/gh-feedstock#installing-gh).
4243

43-
### Windows
44+
### Linux & BSD
45+
46+
`gh` is available via [Homebrew](#homebrew), [Conda](#Conda), and as downloadable binaries from the [releases page][].
4447

45-
`gh` is available via [WinGet][], [scoop][], [Chocolatey][], and as downloadable MSI.
48+
For instructions on specific distributions and package managers, see [Linux & BSD installation](./docs/install_linux.md).
4649

50+
### Windows
51+
52+
`gh` is available via [WinGet][], [scoop][], [Chocolatey][], [Conda](#Conda), and as downloadable MSI.
4753

4854
#### WinGet
4955

@@ -86,13 +92,13 @@ what an official GitHub CLI tool can look like with a fundamentally different de
8692
tools bring GitHub to the terminal, `hub` behaves as a proxy to `git`, and `gh` is a standalone
8793
tool. Check out our [more detailed explanation][gh-vs-hub] to learn more.
8894

89-
9095
[manual]: https://cli.github.com/manual/
9196
[Homebrew]: https://brew.sh
9297
[MacPorts]: https://www.macports.org
9398
[winget]: https://github.com/microsoft/winget-cli
9499
[scoop]: https://scoop.sh
95100
[Chocolatey]: https://chocolatey.org
101+
[Conda]: https://docs.conda.io/en/latest/
96102
[releases page]: https://github.com/cli/cli/releases/latest
97103
[hub]: https://github.com/github/hub
98104
[contributing]: ./.github/CONTRIBUTING.md

api/client.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"regexp"
1212
"strings"
1313

14-
"github.com/cli/cli/internal/ghinstance"
14+
"github.com/cli/cli/v2/internal/ghinstance"
1515
"github.com/henvic/httpretty"
1616
"github.com/shurcooL/graphql"
1717
)
@@ -123,8 +123,8 @@ type graphQLResponse struct {
123123
// GraphQLError is a single error returned in a GraphQL response
124124
type GraphQLError struct {
125125
Type string
126-
Path []string
127126
Message string
127+
// Path []interface // mixed strings and numbers
128128
}
129129

130130
// GraphQLErrorResponse contains errors returned in a GraphQL response
@@ -220,7 +220,6 @@ func (c Client) REST(hostname string, method string, p string, body io.Reader, d
220220
if err != nil {
221221
return err
222222
}
223-
224223
err = json.Unmarshal(b, &data)
225224
if err != nil {
226225
return err
@@ -286,7 +285,10 @@ func HandleHTTPError(resp *http.Response) error {
286285
return httpError
287286
}
288287

289-
messages := []string{parsedBody.Message}
288+
var messages []string
289+
if parsedBody.Message != "" {
290+
messages = append(messages, parsedBody.Message)
291+
}
290292
for _, raw := range parsedBody.Errors {
291293
switch raw[0] {
292294
case '"':
@@ -298,7 +300,7 @@ func HandleHTTPError(resp *http.Response) error {
298300
var errInfo HTTPErrorItem
299301
_ = json.Unmarshal(raw, &errInfo)
300302
msg := errInfo.Message
301-
if errInfo.Code != "custom" {
303+
if errInfo.Code != "" && errInfo.Code != "custom" {
302304
msg = fmt.Sprintf("%s.%s %s", errInfo.Resource, errInfo.Field, errorCodeToMessage(errInfo.Code))
303305
}
304306
if msg != "" {

api/client_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"net/http"
88
"testing"
99

10-
"github.com/cli/cli/pkg/httpmock"
10+
"github.com/cli/cli/v2/pkg/httpmock"
1111
"github.com/stretchr/testify/assert"
1212
)
1313

@@ -129,3 +129,20 @@ func TestRESTError(t *testing.T) {
129129

130130
}
131131
}
132+
133+
func TestHandleHTTPError_GraphQL502(t *testing.T) {
134+
req, err := http.NewRequest("GET", "https://api.github.com/user", nil)
135+
if err != nil {
136+
t.Fatal(err)
137+
}
138+
resp := &http.Response{
139+
Request: req,
140+
StatusCode: 502,
141+
Body: ioutil.NopCloser(bytes.NewBufferString(`{ "data": null, "errors": [{ "message": "Something went wrong" }] }`)),
142+
Header: map[string][]string{"Content-Type": {"application/json"}},
143+
}
144+
err = HandleHTTPError(resp)
145+
if err == nil || err.Error() != "HTTP 502: Something went wrong (https://api.github.com/user)" {
146+
t.Errorf("got error: %v", err)
147+
}
148+
}

api/queries_issue.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"time"
77

8-
"github.com/cli/cli/internal/ghrepo"
8+
"github.com/cli/cli/v2/internal/ghrepo"
99
"github.com/shurcooL/githubv4"
1010
)
1111

@@ -16,8 +16,9 @@ type IssuesPayload struct {
1616
}
1717

1818
type IssuesAndTotalCount struct {
19-
Issues []Issue
20-
TotalCount int
19+
Issues []Issue
20+
TotalCount int
21+
SearchCapped bool
2122
}
2223

2324
type Issue struct {

0 commit comments

Comments
 (0)
X Tutup