X Tutup
Skip to content

Commit db8c2d4

Browse files
committed
Merge remote-tracking branch 'origin/master' into pr-current-branch
2 parents eff8847 + 9a3b032 commit db8c2d4

File tree

22 files changed

+710
-651
lines changed

22 files changed

+710
-651
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: "\U0001F41B Bug report"
3+
about: Report a bug or unexpected behavior while using GitHub CLI
4+
5+
---
6+
7+
### Describe the bug
8+
9+
A clear and concise description of what the bug is. Include version by typing `gh --version`.
10+
11+
### Steps to reproduce the behavior
12+
13+
1. Type this '...'
14+
2. View the output '....'
15+
3. See error
16+
17+
### Expected vs actual behavior
18+
19+
A clear and concise description of what you expected to happen and what actually happened.
20+
21+
### Logs
22+
23+
Paste the activity from your command line. Redact if needed.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: "\U00002B50 Submit a request"
3+
about: Surface a feature or problem that you think should be solved
4+
5+
---
6+
7+
### Describe the feature or problem you’d like to solve
8+
9+
A clear and concise description of what the feature or problem is.
10+
11+
### Proposed solution
12+
13+
How will it benefit CLI and its users?
14+
15+
### Additional context
16+
17+
Add any other context like screenshots or mockups are helpful, if applicable.

.goreleaser.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ archives:
2424
format_overrides:
2525
- goos: windows
2626
format: zip
27+
28+
nfpms:
29+
- license: MIT
30+
maintainer: GitHub
31+
homepage: https://github.com/github/gh-cli
32+
bindir: /usr/local
33+
dependencies:
34+
- git
35+
formats:
36+
- deb
37+
- rpm
38+
2739
changelog:
2840
sort: asc
2941
filters:

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 GitHub Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BUILD_FILES = $(shell go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}}\
22
{{end}}' ./...)
33

4-
GH_VERSION = $(shell go describe --tags 2>/dev/null || git rev-parse --short HEAD)
4+
GH_VERSION = $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD)
55
LDFLAGS := -X github.com/github/gh-cli/command.Version=$(GH_VERSION) $(LDFLAGS)
66
LDFLAGS := -X github.com/github/gh-cli/command.BuildDate=$(shell date +%Y-%m-%d) $(LDFLAGS)
77
ifdef GH_OAUTH_CLIENT_SECRET

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,32 @@ This tool is an endeavor separate from [github/hub](https://github.com/github/hu
88

99
_warning, gh is in a very alpha phase_
1010

11+
## macOS
12+
1113
`brew install github/gh/gh`
1214

13-
That's it. You are now ready to use `gh` on the command line. 🥳
15+
## Debian/Ubuntu Linux
16+
17+
1. `sudo apt install git` if you don't already have git
18+
2. Download the `.deb` file from the [releases page](https://github.com/github/gh-cli/releases/latest)
19+
3. `sudo dpkg -i gh_*_linux_amd64.deb` install the downloaded file
20+
21+
_(Uninstall with `sudo apt remove gh`)_
22+
23+
## Fedora/Centos Linux
24+
25+
1. Download the `.rpm` file from the [releases page](https://github.com/github/gh-cli/releases/latest)
26+
2. `sudo yum localinstall gh_*_linux_amd64.rpm` install the downloaded file
27+
28+
_(Uninstall with `sudo yum remove gh`)_
29+
30+
## Other Linux
31+
32+
1. Download the `_linux_amd64.tar.gz` file from the [releases page](https://github.com/github/gh-cli/releases/latest)
33+
2. `tar -xf gh_*_linux_amd64.tar.gz`
34+
3. Copy the uncompressed `gh` somewhere on your `$PATH` (e.g. `sudo cp gh_*_linux_amd64/bin/gh /usr/local/bin/`)
35+
36+
_(Uninstall with `rm`)_
1437

1538
# Process
1639

@@ -25,4 +48,13 @@ This can all be done from your local terminal.
2548
1. `git tag 'vVERSION_NUMBER' # example git tag 'v0.0.1'`
2649
2. `git push origin vVERSION_NUMBER`
2750
3. Wait a few minutes for the build to run and CI to pass. Look at the [actions tab](https://github.com/github/gh-cli/actions) to check the progress.
28-
4. Go to https://github.com/github/homebrew-gh/releases and look at the release
51+
4. Go to <https://github.com/github/homebrew-gh/releases> and look at the release
52+
53+
# Test a release
54+
55+
A local release can be created for testing without creating anything official on the release page.
56+
57+
1. `git tag 'v6.6.6' # some throwaway version number`
58+
2. `env GH_OAUTH_CLIENT_SECRET=foobar GH_OAUTH_CLIENT_ID=1234 goreleaser --skip-publish --rm-dist`
59+
3. Check and test files in `dist/`
60+
4. `git tag -d v6.6.6 # delete the throwaway tag`

api/queries_issue.go

Lines changed: 35 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,45 @@ package api
22

33
import (
44
"fmt"
5-
"time"
65
)
76

87
type IssuesPayload struct {
98
Assigned []Issue
109
Mentioned []Issue
11-
Recent []Issue
10+
Authored []Issue
1211
}
1312

1413
type Issue struct {
15-
Number int
16-
Title string
17-
URL string
18-
Labels []string
19-
TotalLabelCount int
14+
Number int
15+
Title string
16+
URL string
17+
State string
18+
19+
Labels struct {
20+
Nodes []IssueLabel
21+
TotalCount int
22+
}
23+
}
24+
25+
type IssueLabel struct {
26+
Name string
2027
}
2128

2229
type apiIssues struct {
2330
Issues struct {
24-
Edges []struct {
25-
Node struct {
26-
Number int
27-
Title string
28-
URL string
29-
Labels struct {
30-
Edges []struct {
31-
Node struct {
32-
Name string
33-
}
34-
}
35-
TotalCount int
36-
}
37-
}
38-
}
31+
Nodes []Issue
3932
}
4033
}
4134

4235
const fragments = `
4336
fragment issue on Issue {
4437
number
4538
title
39+
url
40+
state
4641
labels(first: 3) {
47-
edges {
48-
node {
49-
name
50-
}
42+
nodes {
43+
name
5144
}
5245
totalCount
5346
}
@@ -97,35 +90,29 @@ func IssueStatus(client *Client, ghRepo Repo, currentUsername string) (*IssuesPa
9790
type response struct {
9891
Assigned apiIssues
9992
Mentioned apiIssues
100-
Recent apiIssues
93+
Authored apiIssues
10194
}
10295

10396
query := fragments + `
104-
query($owner: String!, $repo: String!, $since: DateTime!, $viewer: String!, $per_page: Int = 10) {
97+
query($owner: String!, $repo: String!, $viewer: String!, $per_page: Int = 10) {
10598
assigned: repository(owner: $owner, name: $repo) {
10699
issues(filterBy: {assignee: $viewer, states: OPEN}, first: $per_page, orderBy: {field: CREATED_AT, direction: DESC}) {
107-
edges {
108-
node {
109-
...issue
110-
}
100+
nodes {
101+
...issue
111102
}
112103
}
113104
}
114105
mentioned: repository(owner: $owner, name: $repo) {
115106
issues(filterBy: {mentioned: $viewer, states: OPEN}, first: $per_page, orderBy: {field: CREATED_AT, direction: DESC}) {
116-
edges {
117-
node {
118-
...issue
119-
}
107+
nodes {
108+
...issue
120109
}
121110
}
122111
}
123-
recent: repository(owner: $owner, name: $repo) {
124-
issues(filterBy: {since: $since, states: OPEN}, first: $per_page, orderBy: {field: CREATED_AT, direction: DESC}) {
125-
edges {
126-
node {
127-
...issue
128-
}
112+
authored: repository(owner: $owner, name: $repo) {
113+
issues(filterBy: {createdBy: $viewer, states: OPEN}, first: $per_page, orderBy: {field: CREATED_AT, direction: DESC}) {
114+
nodes {
115+
...issue
129116
}
130117
}
131118
}
@@ -134,12 +121,10 @@ func IssueStatus(client *Client, ghRepo Repo, currentUsername string) (*IssuesPa
134121

135122
owner := ghRepo.RepoOwner()
136123
repo := ghRepo.RepoName()
137-
since := time.Now().UTC().Add(time.Hour * -24).Format("2006-01-02T15:04:05-0700")
138124
variables := map[string]interface{}{
139125
"owner": owner,
140126
"repo": repo,
141127
"viewer": currentUsername,
142-
"since": since,
143128
}
144129

145130
var resp response
@@ -148,14 +133,10 @@ func IssueStatus(client *Client, ghRepo Repo, currentUsername string) (*IssuesPa
148133
return nil, err
149134
}
150135

151-
assigned := convertAPIToIssues(resp.Assigned)
152-
mentioned := convertAPIToIssues(resp.Mentioned)
153-
recent := convertAPIToIssues(resp.Recent)
154-
155136
payload := IssuesPayload{
156-
assigned,
157-
mentioned,
158-
recent,
137+
Assigned: resp.Assigned.Issues.Nodes,
138+
Mentioned: resp.Mentioned.Issues.Nodes,
139+
Authored: resp.Authored.Issues.Nodes,
159140
}
160141

161142
return &payload, nil
@@ -191,10 +172,8 @@ func IssueList(client *Client, ghRepo Repo, state string, labels []string, assig
191172
query($owner: String!, $repo: String!, $limit: Int, $states: [IssueState!] = OPEN, $labels: [String!], $assignee: String) {
192173
repository(owner: $owner, name: $repo) {
193174
issues(first: $limit, orderBy: {field: CREATED_AT, direction: DESC}, states: $states, labels: $labels, filterBy: {assignee: $assignee}) {
194-
edges {
195-
node {
196-
...issue
197-
}
175+
nodes {
176+
...issue
198177
}
199178
}
200179
}
@@ -221,27 +200,5 @@ func IssueList(client *Client, ghRepo Repo, state string, labels []string, assig
221200
return nil, err
222201
}
223202

224-
issues := convertAPIToIssues(resp.Repository)
225-
return issues, nil
226-
}
227-
228-
func convertAPIToIssues(i apiIssues) []Issue {
229-
var issues []Issue
230-
for _, edge := range i.Issues.Edges {
231-
var labels []string
232-
for _, labelEdge := range edge.Node.Labels.Edges {
233-
labels = append(labels, labelEdge.Node.Name)
234-
}
235-
236-
issue := Issue{
237-
Number: edge.Node.Number,
238-
Title: edge.Node.Title,
239-
URL: edge.Node.URL,
240-
Labels: labels,
241-
TotalLabelCount: edge.Node.Labels.TotalCount,
242-
}
243-
issues = append(issues, issue)
244-
}
245-
246-
return issues
203+
return resp.Repository.Issues.Nodes, nil
247204
}

auth/oauth.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os"
1212
"os/exec"
1313
"runtime"
14+
"strings"
1415
)
1516

1617
func randomString(length int) (string, error) {
@@ -101,11 +102,14 @@ func openInBrowser(url string) error {
101102
args = []string{"open"}
102103
case "windows":
103104
args = []string{"cmd", "/c", "start"}
105+
r := strings.NewReplacer("&", "^&")
106+
url = r.Replace(url)
104107
default:
105108
args = []string{"xdg-open"}
106109
}
107110

108111
args = append(args, url)
109112
cmd := exec.Command(args[0], args[1:]...)
113+
cmd.Stderr = os.Stderr
110114
return cmd.Run()
111115
}

0 commit comments

Comments
 (0)
X Tutup