X Tutup
Skip to content

Commit ec64363

Browse files
committed
Merge remote-tracking branch 'origin' into fix855
2 parents 8487a18 + c77e6af commit ec64363

36 files changed

+957
-304
lines changed

.github/CONTRIBUTING.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
## Contributing
22

3-
[legal]: https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license
4-
[license]: ../LICENSE
5-
[code-of-conduct]: CODE-OF-CONDUCT.md
6-
[bug issues]: https://github.com/cli/cli/issues?q=is%3Aopen+is%3Aissue+label%3Abug
7-
[feature request issues]: https://github.com/cli/cli/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement
8-
93
Hi! Thanks for your interest in contributing to the GitHub CLI!
104

115
We accept pull requests for bug fixes and features where we've discussed the approach in an issue and given the go-ahead for a community member to work on it. We'd also love to hear about ideas for new features as issues.
@@ -17,11 +11,11 @@ Please do:
1711
* Open an issue to propose a significant change.
1812
* Open a pull request to fix a bug.
1913
* Open a pull request to fix documentation about a command.
20-
* Open a pull request for an issue with the `help-wanted` label and leave a comment claiming it.
14+
* Open a pull request for any issue labelled [`help wanted`][hw] or [`good first issue`][gfi].
2115

2216
Please avoid:
2317

24-
* Opening pull requests for issues marked `needs-design`, `needs-investigation`, `needs-user-input`, or `blocked`.
18+
* Opening pull requests for issues marked `needs-design`, `needs-investigation`, or `blocked`.
2519
* Adding installation instructions specifically for your OS/package manager.
2620
* Opening pull requests for any issue marked `core`. These issues require additional context from
2721
the core CLI team at GitHub and any external pull requests will not be accepted.
@@ -52,6 +46,18 @@ We generate manual pages from source on every release. You do not need to submit
5246

5347
## Resources
5448

55-
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
56-
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
57-
- [GitHub Help](https://help.github.com)
49+
- [How to Contribute to Open Source][]
50+
- [Using Pull Requests][]
51+
- [GitHub Help][]
52+
53+
54+
[bug issues]: https://github.com/cli/cli/issues?q=is%3Aopen+is%3Aissue+label%3Abug
55+
[feature request issues]: https://github.com/cli/cli/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement
56+
[hw]: https://github.com/cli/cli/labels/help%20wanted
57+
[gfi]: https://github.com/cli/cli/labels/good%20first%20issue
58+
[legal]: https://docs.github.com/en/free-pro-team@latest/github/site-policy/github-terms-of-service#6-contributions-under-repository-license
59+
[license]: ../LICENSE
60+
[code-of-conduct]: ./CODE-OF-CONDUCT.md
61+
[How to Contribute to Open Source]: https://opensource.guide/how-to-contribute/
62+
[Using Pull Requests]: https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-pull-requests
63+
[GitHub Help]: https://docs.github.com/

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
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/command.Version={{.Version}} -X github.com/cli/cli/command.BuildDate={{time "2006-01-02"}}
18+
- -s -w -X github.com/cli/cli/internal/build.Version={{.Version}} -X github.com/cli/cli/internal/build.Date={{time "2006-01-02"}}
1919
- -X main.updaterEnabled=cli/cli
2020
id: macos
2121
goos: [darwin]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ ifndef CGO_LDFLAGS
1919
export CGO_LDFLAGS := $(LDFLAGS)
2020
endif
2121

22-
GO_LDFLAGS := -X github.com/cli/cli/command.Version=$(GH_VERSION) $(GO_LDFLAGS)
23-
GO_LDFLAGS := -X github.com/cli/cli/command.BuildDate=$(BUILD_DATE) $(GO_LDFLAGS)
22+
GO_LDFLAGS := -X github.com/cli/cli/internal/build.Version=$(GH_VERSION) $(GO_LDFLAGS)
23+
GO_LDFLAGS := -X github.com/cli/cli/internal/build.Date=$(BUILD_DATE) $(GO_LDFLAGS)
2424
ifdef GH_OAUTH_CLIENT_SECRET
2525
GO_LDFLAGS := -X github.com/cli/cli/internal/authflow.oauthClientID=$(GH_OAUTH_CLIENT_ID) $(GO_LDFLAGS)
2626
GO_LDFLAGS := -X github.com/cli/cli/internal/authflow.oauthClientSecret=$(GH_OAUTH_CLIENT_SECRET) $(GO_LDFLAGS)

README.md

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,41 @@
44

55
![screenshot of gh pr status](https://user-images.githubusercontent.com/98482/84171218-327e7a80-aa40-11ea-8cd1-5177fc2d0e72.png)
66

7-
## Availability
8-
9-
GitHub CLI is available for repositories hosted on GitHub.com and GitHub Enterprise Server 2.20+, and to install on macOS, Windows, and Linux.
10-
7+
GitHub CLI is available for repositories hosted on GitHub.com and GitHub Enterprise Server 2.20+, and to install on macOS, Windows, and Linux.
118

129
## Documentation
1310

14-
Read the [official docs][] for usage and more information.
15-
16-
17-
18-
## We want your feedback
11+
[See the manual][manual] for setup and usage instructions.
1912

20-
We'd love to hear your feedback about `gh`. If you spot bugs or have features that you'd really like to see in `gh`, please check out the [contributing page][].
13+
## Contributing
2114

15+
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.
2216

2317

2418
<!-- this anchor is linked to from elsewhere, so avoid renaming it -->
2519
## Installation
2620

2721
### macOS
2822

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

3125
#### Homebrew
3226

33-
|Install:|Upgrade:|
34-
|---|---|
35-
|`brew install gh`|`brew upgrade gh`|
27+
| Install: | Upgrade: |
28+
| ----------------- | ----------------- |
29+
| `brew install gh` | `brew upgrade gh` |
3630

3731
#### MacPorts
3832

39-
|Install:|Upgrade:|
40-
|---|---|
41-
|`sudo port install gh`|`sudo port selfupdate && sudo port upgrade gh`|
42-
43-
33+
| Install: | Upgrade: |
34+
| ---------------------- | ---------------------------------------------- |
35+
| `sudo port install gh` | `sudo port selfupdate && sudo port upgrade gh` |
4436

4537
### Linux
4638

47-
See [Linux installation docs](./docs/install_linux.md).
39+
`gh` is available via [Homebrew](#homebrew), and as downloadable binaries from the [releases page][].
40+
41+
For more information and distro-specific instructions, see the [Linux installation docs](./docs/install_linux.md).
4842

4943
### Windows
5044

@@ -67,10 +61,9 @@ scoop update gh
6761

6862
#### Chocolatey
6963

70-
|Install:|Upgrade:|
71-
|---|---|
72-
|`choco install gh`|`choco upgrade gh`|
73-
64+
| Install: | Upgrade: |
65+
| ------------------ | ------------------ |
66+
| `choco install gh` | `choco upgrade gh` |
7467

7568
#### Signed MSI
7669

@@ -92,13 +85,13 @@ tools bring GitHub to the terminal, `hub` behaves as a proxy to `git`, and `gh`
9285
tool. Check out our [more detailed explanation][gh-vs-hub] to learn more.
9386

9487

95-
[official docs]: https://cli.github.com/manual
88+
[manual]: https://cli.github.com/manual/
9689
[Homebrew]: https://brew.sh
9790
[MacPorts]: https://www.macports.org
9891
[scoop]: https://scoop.sh
9992
[Chocolatey]: https://chocolatey.org
10093
[releases page]: https://github.com/cli/cli/releases/latest
10194
[hub]: https://github.com/github/hub
102-
[contributing page]: https://github.com/cli/cli/blob/trunk/.github/CONTRIBUTING.md
95+
[contributing]: ./.github/CONTRIBUTING.md
10396
[gh-vs-hub]: ./docs/gh-vs-hub.md
10497
[build from source]: ./docs/source.md

api/queries_issue.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ func IssueList(client *Client, repo ghrepo.Interface, state string, labels []str
251251

252252
if milestoneString != "" {
253253
var milestone *RepoMilestone
254-
if milestoneNumber, err := strconv.Atoi(milestoneString); err == nil {
255-
milestone, err = MilestoneByNumber(client, repo, milestoneNumber)
254+
if milestoneNumber, err := strconv.ParseInt(milestoneString, 10, 32); err == nil {
255+
milestone, err = MilestoneByNumber(client, repo, int32(milestoneNumber))
256256
if err != nil {
257257
return nil, err
258258
}
259259
} else {
260-
milestone, err = MilestoneByTitle(client, repo, milestoneString)
260+
milestone, err = MilestoneByTitle(client, repo, "all", milestoneString)
261261
if err != nil {
262262
return nil, err
263263
}
@@ -270,7 +270,7 @@ func IssueList(client *Client, repo ghrepo.Interface, state string, labels []str
270270
variables["milestone"] = milestoneRESTID
271271
}
272272

273-
var response struct {
273+
type responseData struct {
274274
Repository struct {
275275
Issues struct {
276276
TotalCount int
@@ -285,10 +285,12 @@ func IssueList(client *Client, repo ghrepo.Interface, state string, labels []str
285285
}
286286

287287
var issues []Issue
288+
var totalCount int
288289
pageLimit := min(limit, 100)
289290

290291
loop:
291292
for {
293+
var response responseData
292294
variables["limit"] = pageLimit
293295
err := client.GraphQL(repo.RepoHost(), query, variables, &response)
294296
if err != nil {
@@ -297,6 +299,7 @@ loop:
297299
if !response.Repository.HasIssuesEnabled {
298300
return nil, fmt.Errorf("the '%s' repository has disabled issues", ghrepo.FullName(repo))
299301
}
302+
totalCount = response.Repository.Issues.TotalCount
300303

301304
for _, issue := range response.Repository.Issues.Nodes {
302305
issues = append(issues, issue)
@@ -313,7 +316,7 @@ loop:
313316
}
314317
}
315318

316-
res := IssuesAndTotalCount{Issues: issues, TotalCount: response.Repository.Issues.TotalCount}
319+
res := IssuesAndTotalCount{Issues: issues, TotalCount: totalCount}
317320
return &res, nil
318321
}
319322

api/queries_issue_test.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"io/ioutil"
77
"testing"
88

9+
"github.com/stretchr/testify/assert"
10+
911
"github.com/cli/cli/internal/ghrepo"
1012
"github.com/cli/cli/pkg/httpmock"
1113
)
@@ -68,3 +70,76 @@ func TestIssueList(t *testing.T) {
6870
t.Errorf("expected %q, got %q", "ENDCURSOR", endCursor)
6971
}
7072
}
73+
74+
func TestIssueList_pagination(t *testing.T) {
75+
http := &httpmock.Registry{}
76+
client := NewClient(ReplaceTripper(http))
77+
78+
http.StubResponse(200, bytes.NewBufferString(`
79+
{ "data": { "repository": {
80+
"hasIssuesEnabled": true,
81+
"issues": {
82+
"nodes": [
83+
{
84+
"title": "issue1",
85+
"labels": { "nodes": [ { "name": "bug" } ], "totalCount": 1 },
86+
"assignees": { "nodes": [ { "login": "user1" } ], "totalCount": 1 }
87+
}
88+
],
89+
"pageInfo": {
90+
"hasNextPage": true,
91+
"endCursor": "ENDCURSOR"
92+
},
93+
"totalCount": 2
94+
}
95+
} } }
96+
`))
97+
http.StubResponse(200, bytes.NewBufferString(`
98+
{ "data": { "repository": {
99+
"hasIssuesEnabled": true,
100+
"issues": {
101+
"nodes": [
102+
{
103+
"title": "issue2",
104+
"labels": { "nodes": [ { "name": "enhancement" } ], "totalCount": 1 },
105+
"assignees": { "nodes": [ { "login": "user2" } ], "totalCount": 1 }
106+
}
107+
],
108+
"pageInfo": {
109+
"hasNextPage": false,
110+
"endCursor": "ENDCURSOR"
111+
},
112+
"totalCount": 2
113+
}
114+
} } }
115+
`))
116+
117+
repo := ghrepo.New("OWNER", "REPO")
118+
res, err := IssueList(client, repo, "", nil, "", 0, "", "", "")
119+
if err != nil {
120+
t.Fatalf("IssueList() error = %v", err)
121+
}
122+
123+
assert.Equal(t, 2, res.TotalCount)
124+
assert.Equal(t, 2, len(res.Issues))
125+
126+
getLabels := func(i Issue) []string {
127+
var labels []string
128+
for _, l := range i.Labels.Nodes {
129+
labels = append(labels, l.Name)
130+
}
131+
return labels
132+
}
133+
getAssignees := func(i Issue) []string {
134+
var logins []string
135+
for _, u := range i.Assignees.Nodes {
136+
logins = append(logins, u.Login)
137+
}
138+
return logins
139+
}
140+
141+
assert.Equal(t, []string{"bug"}, getLabels(res.Issues[0]))
142+
assert.Equal(t, []string{"user1"}, getAssignees(res.Issues[0]))
143+
assert.Equal(t, []string{"enhancement"}, getLabels(res.Issues[1]))
144+
assert.Equal(t, []string{"user2"}, getAssignees(res.Issues[1]))
145+
}

api/queries_org.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
// OrganizationProjects fetches all open projects for an organization
1111
func OrganizationProjects(client *Client, repo ghrepo.Interface) ([]RepoProject, error) {
12-
var query struct {
12+
type responseData struct {
1313
Organization struct {
1414
Projects struct {
1515
Nodes []RepoProject
@@ -30,6 +30,7 @@ func OrganizationProjects(client *Client, repo ghrepo.Interface) ([]RepoProject,
3030

3131
var projects []RepoProject
3232
for {
33+
var query responseData
3334
err := gql.QueryNamed(context.Background(), "OrganizationProjectList", &query, variables)
3435
if err != nil {
3536
return nil, err
@@ -52,7 +53,7 @@ type OrgTeam struct {
5253

5354
// OrganizationTeams fetches all the teams in an organization
5455
func OrganizationTeams(client *Client, repo ghrepo.Interface) ([]OrgTeam, error) {
55-
var query struct {
56+
type responseData struct {
5657
Organization struct {
5758
Teams struct {
5859
Nodes []OrgTeam
@@ -73,6 +74,7 @@ func OrganizationTeams(client *Client, repo ghrepo.Interface) ([]OrgTeam, error)
7374

7475
var teams []OrgTeam
7576
for {
77+
var query responseData
7678
err := gql.QueryNamed(context.Background(), "OrganizationTeamList", &query, variables)
7779
if err != nil {
7880
return nil, err

0 commit comments

Comments
 (0)
X Tutup