Skip to content

Commit d583f8b

Browse files
committed
Merge remote-tracking branch 'origin' into issue_list
2 parents 15ec2b7 + 352999e commit d583f8b

Some content is hidden

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

41 files changed

+1526
-445
lines changed

.github/PULL_REQUEST_TEMPLATE/bug_fix.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
---
2+
name: "\U0001F41B Bug fix"
3+
about: Fix a bug in GitHub CLI
4+
5+
---
6+
17
<!--
28
Please make sure you read our contributing guidelines at
39
https://github.com/cli/cli/blob/trunk/.github/CONTRIBUTING.md
4-
before opening opening a pull request. Thanks!
10+
before opening a pull request. Thanks!
511
-->
612

713
## Summary

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
linters:
2+
enable:
3+
gofmt

.goreleaser.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ nfpms:
8282
bindir: /usr/local
8383
dependencies:
8484
- git
85+
description: GitHub’s official command line tool.
8586
formats:
8687
- deb
8788
- rpm

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ the terminal next to where you are already working with `git` and your code.
77

88
## Availability
99

10-
While in beta, GitHub CLI is available for repos hosted on GitHub.com only. It does not currently support repositories hosted on GitHub Enterprise Server or other hosting providers. We are planning support for GitHub Enterprise Server after GitHub CLI is out of beta (likely toward the end of 2020), and we want to ensure that the API endpoints we use are more widely available for GHES versions that most GitHub customers are on.
10+
While in beta, GitHub CLI is available for repos hosted on GitHub.com only. It currently does not support repositories hosted on GitHub Enterprise Server or other hosting providers. We are planning on adding support for GitHub Enterprise Server after GitHub CLI is out of beta (likely towards the end of 2020), and we want to ensure that the API endpoints we use are more widely available for GHES versions that most GitHub customers are on.
1111

1212
## We need your feedback
1313

14-
GitHub CLI is currently early in its development, and we're hoping to get feedback from people using it.
14+
GitHub CLI is currently in its early development stages, and we're hoping to get feedback from people using it.
1515

1616
If you've installed and used `gh`, we'd love for you to take a short survey here (no more than five minutes): https://forms.gle/umxd3h31c7aMQFKG7
1717

@@ -31,9 +31,9 @@ Read the [official docs](https://cli.github.com/manual/) for more information.
3131

3232
## Comparison with hub
3333

34-
For many years, [hub][] was the unofficial GitHub CLI tool. `gh` is a new project for us to explore
34+
For many years, [hub][] was the unofficial GitHub CLI tool. `gh` is a new project that helps us explore
3535
what an official GitHub CLI tool can look like with a fundamentally different design. While both
36-
tools bring GitHub to the terminal, `hub` behaves as a proxy to `git` and `gh` is a standalone
36+
tools bring GitHub to the terminal, `hub` behaves as a proxy to `git`, and `gh` is a standalone
3737
tool. Check out our [more detailed explanation](/docs/gh-vs-hub.md) to learn more.
3838

3939

@@ -46,15 +46,31 @@ tool. Check out our [more detailed explanation](/docs/gh-vs-hub.md) to learn mor
4646

4747
#### Homebrew
4848

49-
Install: `brew install github/gh/gh`
49+
Install:
50+
51+
```bash
52+
brew install github/gh/gh
53+
```
5054

51-
Upgrade: `brew upgrade gh`
55+
Upgrade:
56+
57+
```bash
58+
brew upgrade gh
59+
```
5260

5361
#### MacPorts
5462

55-
Install: `sudo port install gh`
63+
Install:
64+
65+
```bash
66+
sudo port install gh
67+
```
68+
69+
Upgrade:
5670

57-
Upgrade: `sudo port selfupdate && sudo port upgrade gh`
71+
```bash
72+
sudo port selfupdate && sudo port upgrade gh
73+
```
5874

5975
### Windows
6076

@@ -64,24 +80,28 @@ Upgrade: `sudo port selfupdate && sudo port upgrade gh`
6480

6581
Install:
6682

67-
```
83+
```powershell
6884
scoop bucket add github-gh https://github.com/cli/scoop-gh.git
6985
scoop install gh
7086
```
7187

72-
Upgrade: `scoop update gh`
88+
Upgrade:
89+
90+
```powershell
91+
scoop update gh
92+
```
7393

7494
#### Chocolatey
7595

7696
Install:
7797

78-
```
98+
```powershell
7999
choco install gh
80100
```
81101

82102
Upgrade:
83103

84-
```
104+
```powershell
85105
choco upgrade gh
86106
```
87107

@@ -122,7 +142,7 @@ Install and upgrade:
122142
Arch Linux users can install from the AUR: https://aur.archlinux.org/packages/github-cli/
123143

124144
```bash
125-
$ yay -S github-cli
145+
yay -S github-cli
126146
```
127147

128148
### Other platforms

api/client.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ func NewClient(opts ...ClientOption) *Client {
3535
func AddHeader(name, value string) ClientOption {
3636
return func(tr http.RoundTripper) http.RoundTripper {
3737
return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
38-
req.Header.Add(name, value)
38+
// prevent the token from leaking to non-GitHub hosts
39+
// TODO: GHE support
40+
if !strings.EqualFold(name, "Authorization") || strings.HasSuffix(req.URL.Hostname(), ".github.com") {
41+
req.Header.Add(name, value)
42+
}
3943
return tr.RoundTrip(req)
4044
}}
4145
}
@@ -45,7 +49,11 @@ func AddHeader(name, value string) ClientOption {
4549
func AddHeaderFunc(name string, value func() string) ClientOption {
4650
return func(tr http.RoundTripper) http.RoundTripper {
4751
return &funcTripper{roundTrip: func(req *http.Request) (*http.Response, error) {
48-
req.Header.Add(name, value())
52+
// prevent the token from leaking to non-GitHub hosts
53+
// TODO: GHE support
54+
if !strings.EqualFold(name, "Authorization") || strings.HasSuffix(req.URL.Hostname(), ".github.com") {
55+
req.Header.Add(name, value())
56+
}
4957
return tr.RoundTrip(req)
5058
}}
5159
}

command/alias.go

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"sort"
66
"strings"
77

8+
"github.com/MakeNowJust/heredoc"
89
"github.com/cli/cli/utils"
910
"github.com/google/shlex"
1011
"github.com/spf13/cobra"
@@ -23,24 +24,30 @@ var aliasCmd = &cobra.Command{
2324
}
2425

2526
var aliasSetCmd = &cobra.Command{
26-
Use: "set <alias> <expansion>",
27+
Use: "set <alias> <expansion>",
28+
Short: "Create a shortcut for a gh command",
29+
Long: `Declare a word as a command alias that will expand to the specified command.
30+
31+
The expansion may specify additional arguments and flags. If the expansion
32+
includes positional placeholders such as '$1', '$2', etc., any extra arguments
33+
that follow the invocation of an alias will be inserted appropriately.`,
34+
Example: heredoc.Doc(`
35+
$ gh alias set pv 'pr view'
36+
$ gh pv -w 123
37+
#=> gh pr view -w 123
38+
39+
$ gh alias set bugs 'issue list --label="bugs"'
40+
41+
$ gh alias set epicsBy 'issue list --author="$1" --label="epic"'
42+
$ gh epicsBy vilmibm
43+
#=> gh issue list --author="vilmibm" --label="epic"
44+
`),
45+
Args: cobra.MinimumNArgs(2),
46+
RunE: aliasSet,
47+
2748
// NB: this allows a user to eschew quotes when specifiying an alias expansion. We'll have to
2849
// revisit it if we ever want to add flags to alias set but we have no current plans for that.
2950
DisableFlagParsing: true,
30-
Short: "Create a shortcut for a gh command",
31-
Long: `This command lets you write your own shortcuts for running gh. They can be simple strings or accept placeholder arguments.`,
32-
Example: `
33-
gh alias set pv 'pr view'
34-
# gh pv -w 123 -> gh pr view -w 123.
35-
36-
gh alias set bugs 'issue list --label="bugs"'
37-
# gh bugs -> gh issue list --label="bugs".
38-
39-
gh alias set epicsBy 'issue list --author="$1" --label="epic"'
40-
# gh epicsBy vilmibm -> gh issue list --author="$1" --label="epic"
41-
`,
42-
Args: cobra.MinimumNArgs(2),
43-
RunE: aliasSet,
4451
}
4552

4653
func aliasSet(cmd *cobra.Command, args []string) error {
@@ -168,11 +175,10 @@ func aliasList(cmd *cobra.Command, args []string) error {
168175
}
169176

170177
var aliasDeleteCmd = &cobra.Command{
171-
Use: "delete <alias>",
172-
Short: "Delete an alias.",
173-
Args: cobra.ExactArgs(1),
174-
Example: "gh alias delete co",
175-
RunE: aliasDelete,
178+
Use: "delete <alias>",
179+
Short: "Delete an alias.",
180+
Args: cobra.ExactArgs(1),
181+
RunE: aliasDelete,
176182
}
177183

178184
func aliasDelete(cmd *cobra.Command, args []string) error {

command/config.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package command
22

33
import (
44
"fmt"
5+
6+
"github.com/MakeNowJust/heredoc"
57
"github.com/spf13/cobra"
68
)
79

@@ -21,36 +23,32 @@ func init() {
2123

2224
var configCmd = &cobra.Command{
2325
Use: "config",
24-
Short: "Set and get gh settings",
25-
Long: `Get and set key/value strings.
26+
Short: "Manage configuration for gh",
27+
Long: `Display or change configuration settings for gh.
2628
2729
Current respected settings:
28-
- git_protocol: https or ssh. Default is https.
30+
- git_protocol: "https" or "ssh". Default is "https".
2931
- editor: if unset, defaults to environment variables.
3032
`,
3133
}
3234

3335
var configGetCmd = &cobra.Command{
3436
Use: "get <key>",
35-
Short: "Prints the value of a given configuration key",
36-
Long: `Get the value for a given configuration key.
37-
38-
Examples:
39-
$ gh config get git_protocol
40-
https
41-
`,
37+
Short: "Print the value of a given configuration key",
38+
Example: heredoc.Doc(`
39+
$ gh config get git_protocol
40+
https
41+
`),
4242
Args: cobra.ExactArgs(1),
4343
RunE: configGet,
4444
}
4545

4646
var configSetCmd = &cobra.Command{
4747
Use: "set <key> <value>",
48-
Short: "Updates configuration with the value of a given key",
49-
Long: `Update the configuration by setting a key to a value.
50-
51-
Examples:
52-
$ gh config set editor vim
53-
`,
48+
Short: "Update configuration with a value for the given key",
49+
Example: heredoc.Doc(`
50+
$ gh config set editor vim
51+
`),
5452
Args: cobra.ExactArgs(2),
5553
RunE: configSet,
5654
}

command/credits.go

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

14+
"github.com/MakeNowJust/heredoc"
1415
"github.com/spf13/cobra"
1516
"golang.org/x/crypto/ssh/terminal"
1617

@@ -44,11 +45,16 @@ var creditsCmd = &cobra.Command{
4445
Use: "credits",
4546
Short: "View credits for this tool",
4647
Long: `View animated credits for gh, the tool you are currently using :)`,
47-
Example: `gh credits # see a credits animation for this project
48-
gh credits owner/repo # see a credits animation for owner/repo
49-
gh credits -s # display a non-animated thank you
50-
gh credits | cat # just print the contributors, one per line
51-
`,
48+
Example: heredoc.Doc(`
49+
# see a credits animation for this project
50+
$ gh credits
51+
52+
# display a non-animated thank you
53+
$ gh credits -s
54+
55+
# just print the contributors, one per line
56+
$ gh credits | cat
57+
`),
5258
Args: cobra.ExactArgs(0),
5359
RunE: ghCredits,
5460
Hidden: true,

command/gist.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"path"
1010

11+
"github.com/MakeNowJust/heredoc"
1112
"github.com/cli/cli/api"
1213
"github.com/cli/cli/utils"
1314
"github.com/spf13/cobra"
@@ -27,21 +28,30 @@ var gistCmd = &cobra.Command{
2728
}
2829

2930
var gistCreateCmd = &cobra.Command{
30-
Use: `create {<filename>|-}...`,
31+
Use: `create [<filename>... | -]`,
3132
Short: "Create a new gist",
32-
Long: `gh gist create: create gists
33-
34-
Gists can be created from one or many files. This command can also read from STDIN. By default, gists are private; use --public to change this.
35-
36-
Examples
37-
38-
gh gist create hello.py # turn file hello.py into a gist
39-
gh gist create --public hello.py # turn file hello.py into a public gist
40-
gh gist create -d"a file!" hello.py # turn file hello.py into a gist, with description
41-
gh gist create hello.py world.py cool.txt # make a gist out of several files
42-
gh gist create - # read from STDIN to create a gist
43-
cat cool.txt | gh gist create # read the output of another command and make a gist out of it
44-
`,
33+
Long: `Create a new GitHub gist with given contents.
34+
35+
Gists can be created from one or multiple files. Alternatively, pass "-" as
36+
file name to read from standard input.
37+
38+
By default, gists are private; use '--public' to make publicly listed ones.`,
39+
Example: heredoc.Doc(`
40+
# publish file 'hello.py' as a public gist
41+
$ gh gist create --public hello.py
42+
43+
# create a gist with a description
44+
$ gh gist create hello.py -d "my Hello-World program in Python"
45+
46+
# create a gist containing several files
47+
$ gh gist create hello.py world.py cool.txt
48+
49+
# read from standard input to create a gist
50+
$ gh gist create -
51+
52+
# create a gist from output piped from another command
53+
$ cat cool.txt | gh gist create
54+
`),
4555
RunE: gistCreate,
4656
}
4757

0 commit comments

Comments
 (0)