X Tutup
Skip to content

Commit 2df5281

Browse files
committed
Merge branch 'master' into reviewers-in-pr-view
2 parents 6223a2c + d14b5d3 commit 2df5281

13 files changed

+61
-200
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,19 @@ tool. Check out our [more detailed explanation](/docs/gh-vs-hub.md) to learn mor
4141

4242
### macOS
4343

44+
`gh` is available via Homebrew and MacPorts.
45+
46+
#### Homebrew
47+
4448
Install: `brew install github/gh/gh`
4549

46-
Upgrade: `brew update && brew upgrade gh`
50+
Upgrade: `brew upgrade gh`
51+
52+
#### MacPorts
53+
54+
Install: `sudo port install gh`
55+
56+
Upgrade: `sudo port selfupdate && sudo port upgrade gh`
4757

4858
### Windows
4959

api/queries_pr.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,6 @@ type PullRequest struct {
104104
Milestone struct {
105105
Title string
106106
}
107-
Participants struct {
108-
Nodes []struct {
109-
Login string
110-
}
111-
TotalCount int
112-
}
113107
}
114108

115109
type NotFoundError struct {
@@ -418,12 +412,6 @@ func PullRequestByNumber(client *Client, repo ghrepo.Interface, number int) (*Pu
418412
milestone{
419413
title
420414
}
421-
participants(first: 100) {
422-
nodes {
423-
login
424-
}
425-
totalCount
426-
}
427415
}
428416
}
429417
}`
@@ -521,12 +509,6 @@ func PullRequestForBranch(client *Client, repo ghrepo.Interface, baseBranch, hea
521509
milestone{
522510
title
523511
}
524-
participants(first: 100) {
525-
nodes {
526-
login
527-
}
528-
totalCount
529-
}
530512
}
531513
}
532514
}

cmd/gh/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ func printError(out io.Writer, err error, cmd *cobra.Command, debug bool) {
7070
}
7171

7272
func shouldCheckForUpdate() bool {
73-
return updaterEnabled != "" && utils.IsTerminal(os.Stderr)
73+
return updaterEnabled != "" && !isCompletionCommand() && utils.IsTerminal(os.Stderr)
74+
}
75+
76+
func isCompletionCommand() bool {
77+
return len(os.Args) > 1 && os.Args[1] == "completion"
7478
}
7579

7680
func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {

command/completion.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
package command
22

33
import (
4+
"errors"
45
"fmt"
6+
"os"
57

68
"github.com/cli/cli/internal/cobrafish"
9+
"github.com/cli/cli/utils"
710
"github.com/spf13/cobra"
811
)
912

1013
func init() {
1114
RootCmd.AddCommand(completionCmd)
12-
completionCmd.Flags().StringP("shell", "s", "bash", "Shell type: {bash|zsh|fish|powershell}")
15+
completionCmd.Flags().StringP("shell", "s", "", "Shell type: {bash|zsh|fish|powershell}")
1316
}
1417

1518
var completionCmd = &cobra.Command{
1619
Use: "completion",
1720
Short: "Generate shell completion scripts",
1821
Long: `Generate shell completion scripts for GitHub CLI commands.
1922
23+
The output of this command will be computer code and is meant to be saved to a
24+
file or immediately evaluated by an interactive shell.
25+
2026
For example, for bash you could add this to your '~/.bash_profile':
2127
22-
eval "$(gh completion)"
28+
eval "$(gh completion -s bash)"
2329
2430
When installing GitHub CLI through a package manager, however, it's possible that
2531
no additional shell configuration is necessary to gain completion support. For
@@ -31,6 +37,19 @@ Homebrew, see <https://docs.brew.sh/Shell-Completion>
3137
return err
3238
}
3339

40+
if shellType == "" {
41+
out := cmd.OutOrStdout()
42+
isTTY := false
43+
if outFile, isFile := out.(*os.File); isFile {
44+
isTTY = utils.IsTerminal(outFile)
45+
}
46+
47+
if isTTY {
48+
return errors.New("error: the value for `--shell` is required\nsee `gh help completion` for more information")
49+
}
50+
shellType = "bash"
51+
}
52+
3453
switch shellType {
3554
case "bash":
3655
return RootCmd.GenBashCompletion(cmd.OutOrStdout())

command/issue.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func init() {
3838
issueListCmd.Flags().StringP("author", "A", "", "Filter by author")
3939

4040
issueCmd.AddCommand(issueViewCmd)
41-
issueViewCmd.Flags().BoolP("web", "w", false, "Open issue in browser")
41+
issueViewCmd.Flags().BoolP("web", "w", false, "Open an issue in the browser")
4242
}
4343

4444
var issueCmd = &cobra.Command{
@@ -74,7 +74,10 @@ var issueViewCmd = &cobra.Command{
7474
return nil
7575
},
7676
Short: "View an issue",
77-
RunE: issueView,
77+
Long: `Display the title, body, and other information about an issue.
78+
79+
With '--web', open the issue in a web browser instead.`,
80+
RunE: issueView,
7881
}
7982

8083
func issueList(cmd *cobra.Command, args []string) error {

command/pr.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func init() {
3232
prListCmd.Flags().StringSliceP("label", "l", nil, "Filter by label")
3333
prListCmd.Flags().StringP("assignee", "a", "", "Filter by assignee")
3434

35-
prViewCmd.Flags().BoolP("web", "w", false, "Open pull request in browser")
35+
prViewCmd.Flags().BoolP("web", "w", false, "Open a pull request in the browser")
3636
}
3737

3838
var prCmd = &cobra.Command{
@@ -57,11 +57,13 @@ var prStatusCmd = &cobra.Command{
5757
}
5858
var prViewCmd = &cobra.Command{
5959
Use: "view [{<number> | <url> | <branch>}]",
60-
Short: "View a pull request in the browser",
61-
Long: `View a pull request specified by the argument.
60+
Short: "View a pull request",
61+
Long: `Display the title, body, and other information about a pull request.
6262
63-
Without an argument, the pull request that belongs to the current
64-
branch is displayed.`,
63+
Without an argument, the pull request that belongs to the current branch
64+
is displayed.
65+
66+
With '--web', open the pull request in a web browser instead.`,
6567
RunE: prView,
6668
}
6769

@@ -521,23 +523,6 @@ func prProjectList(pr api.PullRequest) string {
521523
return list
522524
}
523525

524-
func prParticipantList(pr api.PullRequest) string {
525-
if len(pr.Participants.Nodes) == 0 {
526-
return ""
527-
}
528-
529-
participantNames := make([]string, 0, len(pr.Participants.Nodes))
530-
for _, participant := range pr.Participants.Nodes {
531-
participantNames = append(participantNames, participant.Login)
532-
}
533-
534-
list := strings.Join(participantNames, ", ")
535-
if pr.Participants.TotalCount > len(pr.Participants.Nodes) {
536-
list += ", …"
537-
}
538-
return list
539-
}
540-
541526
var prURLRE = regexp.MustCompile(`^https://github\.com/([^/]+)/([^/]+)/pull/(\d+)`)
542527

543528
func prFromURL(arg string) (string, ghrepo.Interface) {

command/pr_checkout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ var prCheckoutCmd = &cobra.Command{
123123
Short: "Check out a pull request in Git",
124124
Args: func(cmd *cobra.Command, args []string) error {
125125
if len(args) < 1 {
126-
return errors.New("requires a PR number as an argument")
126+
return errors.New("requires a pull request number as an argument")
127127
}
128128
return nil
129129
},

command/repo.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func init() {
3737
repoForkCmd.Flags().Lookup("remote").NoOptDefVal = "true"
3838

3939
repoCmd.AddCommand(repoViewCmd)
40-
repoViewCmd.Flags().BoolP("web", "w", false, "Open repository in browser")
40+
repoViewCmd.Flags().BoolP("web", "w", false, "Open a repository in the browser")
4141
}
4242

4343
var repoCmd = &cobra.Command{
@@ -51,7 +51,7 @@ A repository can be supplied as an argument in any of the following formats:
5151
}
5252

5353
var repoCloneCmd = &cobra.Command{
54-
Use: "clone <repo> [<directory>]",
54+
Use: "clone <repository> [<directory>]",
5555
Args: cobra.MinimumNArgs(1),
5656
Short: "Clone a repository locally",
5757
Long: `Clone a GitHub repository locally.
@@ -80,10 +80,12 @@ With no argument, creates a fork of the current repository. Otherwise, forks the
8080

8181
var repoViewCmd = &cobra.Command{
8282
Use: "view [<repository>]",
83-
Short: "View a repository in the browser",
84-
Long: `View a GitHub repository.
83+
Short: "View a repository",
84+
Long: `Display the description and the README of a GitHub repository.
8585
86-
With no argument, the repository for the current directory is displayed.`,
86+
With no argument, the repository for the current directory is displayed.
87+
88+
With '--web', open the repository in a web browser instead.`,
8789
RunE: repoView,
8890
}
8991

@@ -169,7 +171,7 @@ func addUpstreamRemote(parentRepo ghrepo.Interface, cloneDir string) error {
169171
// TODO: support SSH remote URLs
170172
upstreamURL := fmt.Sprintf("https://github.com/%s.git", ghrepo.FullName(parentRepo))
171173

172-
cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "upstream", upstreamURL)
174+
cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "-f", "upstream", upstreamURL)
173175
cloneCmd.Stdout = os.Stdout
174176
cloneCmd.Stderr = os.Stderr
175177
return run.PrepareCmd(cloneCmd).Run()

command/repo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func TestRepoFork_outside_yes(t *testing.T) {
186186
eq(t, output.Stderr(), "")
187187

188188
eq(t, strings.Join(cs.Calls[0].Args, " "), "git clone https://github.com/someone/repo.git")
189-
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add upstream https://github.com/OWNER/REPO.git")
189+
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add -f upstream https://github.com/OWNER/REPO.git")
190190

191191
test.ExpectLines(t, output.String(),
192192
"Created fork someone/REPO",
@@ -219,7 +219,7 @@ func TestRepoFork_outside_survey_yes(t *testing.T) {
219219
eq(t, output.Stderr(), "")
220220

221221
eq(t, strings.Join(cs.Calls[0].Args, " "), "git clone https://github.com/someone/repo.git")
222-
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add upstream https://github.com/OWNER/REPO.git")
222+
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add -f upstream https://github.com/OWNER/REPO.git")
223223

224224
test.ExpectLines(t, output.String(),
225225
"Created fork someone/REPO",
@@ -484,7 +484,7 @@ func TestRepoClone_hasParent(t *testing.T) {
484484
}
485485

486486
eq(t, cs.Count, 2)
487-
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C REPO remote add upstream https://github.com/hubot/ORIG.git")
487+
eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C REPO remote add -f upstream https://github.com/hubot/ORIG.git")
488488
}
489489

490490
func TestRepoCreate(t *testing.T) {

test/fixtures/prViewPreview.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@
2525
"milestone": {
2626
"title": ""
2727
},
28-
"participants": {
29-
"nodes": [
30-
{
31-
"login": "marseilles"
32-
}
33-
],
34-
"totalcount": 1
35-
},
3628
"commits": {
3729
"totalCount": 12
3830
},

0 commit comments

Comments
 (0)
X Tutup