Commit graph

124 commits

Author SHA1 Message Date
Mislav Marohnić
eab5af9449 Merge remote-tracking branch 'origin' into cobra1.0 2020-05-28 15:15:20 +02:00
Mislav Marohnić
13ba0aa56e Respect GITHUB_TOKEN in api command 2020-05-27 13:09:05 +02:00
Mislav Marohnić
2e93a065b1 Merge remote-tracking branch 'origin/master' into api-command 2020-05-27 12:56:06 +02:00
Mislav Marohnić
c6643821dc Don't offer to reauthenticate for gist if GITHUB_TOKEN is used 2020-05-27 11:57:03 +02:00
Mislav Marohnić
ab0e43c6c8 Merge remote-tracking branch 'origin/master' into auth-from-env 2020-05-27 11:44:19 +02:00
Mislav Marohnić
108f7bd66c Dirty workaround to display helpful error message on mistyped subcommands
When executing `gh pr re` (note the incomplete command name), Cobra
would just display the help text for `gh pr` on standard output, exit
with status 0, and not print any message that you have mistyped the
"re" subcommand. Each part of this behavior is wrong.

This workaround makes sure that the helpful error message is printed on
stderr:

    $ gh pr re
    unknown command "re" for "gh pr"

    Did you mean this?
            reopen
            ready
            review

However, the exit status is still 0, whereas it should be non-zero.
Since `HelpFunc` does not return an error argument, we cannot trigger an
error status from this workaround.
2020-05-22 19:02:34 +02:00
vilmibm
509be34af6 Merge remote-tracking branch 'origin/master' into wingkwong/master 2020-05-20 17:08:31 -05:00
Mislav Marohnić
db9014fd7f Respect auth token from GITHUB_TOKEN environment variable
If GITHUB_TOKEN is non-blank, it overrides authentication info found in
the config file. The config file is, in fact, never consulted.
2020-05-20 17:35:10 +02:00
Mislav Marohnić
bef62faaea Make NewCmdApi testable 2020-05-20 15:21:35 +02:00
Mislav Marohnić
d8146cd16e Extract cmdutil package 2020-05-20 15:21:31 +02:00
Mislav Marohnić
90fa193eaf Promote api command to a pkg/cmd/api package 2020-05-20 15:21:31 +02:00
Mislav Marohnić
4d11732a47
Merge pull request #943 from cli/reauth-bug
pass apiClient to determineBaseRepo
2020-05-18 13:16:07 +02:00
Kevin Bluer
d440a95aed
Improved error message when "owner/repo" format not provided (#919)
Fixes #882
2020-05-18 11:13:48 +02:00
vilmibm
780875d645 fix tests 2020-05-15 16:47:11 -05:00
vilmibm
96ba1eacef undo initial thing 2020-05-15 16:44:51 -05:00
vilmibm
bf05975ceb Revert "small repo fix"
This reverts commit 08e9cdaee1.
2020-05-15 16:40:47 -05:00
vilmibm
7decae71fc untested first pass on ensureScopes 2020-05-15 16:40:13 -05:00
vilmibm
c8c807b954 pass apiClient to determineBaseRepo
Our code had an unspoken assumption that only one apiClient is created
during the course of a command. Violating this assumption is fine in
almost all cases, but not when we need to do a re-auth to add a new
oauth scope to a user's token.

There is likely a more elegant solution to the problem but until then
this changes determineBaseRepo to use an existing apiClient.
2020-05-15 15:29:33 -05:00
vilmibm
08e9cdaee1 small repo fix 2020-05-15 10:25:40 -05:00
vilmibm
3b62d79e81 notes 2020-05-15 09:52:06 -05:00
vilmibm
a62f2987c0 stray debug 2020-05-13 14:59:14 -05:00
vilmibm
cc1ffb0aea pass apiClient to determineBaseRepo
Our code had an unspoken assumption that only one apiClient is created
during the course of a command. Violating this assumption is fine in
almost all cases, but not when we need to do a re-auth to add a new
oauth scope to a user's token.

There is likely a more elegant solution to the problem but until then
this changes determineBaseRepo to use an existing apiClient.
2020-05-13 14:55:49 -05:00
vilmibm
3a7f56456e tweak reauth code and request a new scope 2020-05-13 14:24:29 -05:00
vilmibm
ed1a3a60fd Merge remote-tracking branch 'origin/master' into wingkwong/master 2020-05-13 13:43:09 -05:00
vilmibm
c8e9768bf5 slopwip on interactive review 2020-05-11 15:28:12 -05:00
vilmibm
1675a677d6 hide credits from main help 2020-05-11 12:04:24 -05:00
Mislav Marohnić
1f0db96f2a Avoid relying on Cobra help internals 2020-05-11 12:38:22 +02:00
Corey Johnson
70223d1e32 Don't always use the root command help
Co-Authored-By: Nate Smith <vilmibm@neongrid.space>
2020-05-08 09:19:19 -07:00
Nate Smith
d908320050
Merge pull request #786 from cli/oauth-read-org
Ask for `read:org` OAuth scope, warn for outdated tokens
2020-04-28 20:23:44 -05:00
Nate Smith
fb7b5446d1
Update command/root.go
Co-Authored-By: Corey Johnson <probablycorey@gmail.com>
2020-04-28 20:19:52 -05:00
Nate Smith
ef5932f6cb
Merge pull request #821 from cli/basic-client-auth
Fix gh updater mechanism for unauthenticated users
2020-04-28 20:15:17 -05:00
Corey Johnson
3d2ee3c9b2 fix whitespace 2020-04-27 10:07:47 -07:00
Mislav Marohnić
3aaa231cc5 Guide user through re-authorization flow if read:org scope is missing
How this works for people with existing OAuth tokens:

    $ gh issue list -L1
    Notice: additional authorization required
    Press Enter to open github.com in your browser...
    [auth flow in the browser...]
    Authentication complete. Press Enter to continue...

    Showing 1 of 132 issues in cli/cli
    ...

Users of Personal Access Tokens get a different notice:

    Warning: gh now requires the `read:org` OAuth scope.
    Visit https://github.com/settings/tokens and edit your token to enable `read:org`
    or generate a new token and paste it via `gh config set -h github.com oauth_token MYTOKEN`
2020-04-23 18:20:21 +02:00
Mislav Marohnić
84ac3d412e Fix gh updater mechanism for unauthenticated users
Per code documentation: "BasicClient returns an API client that borrows
from but does not depend on user configuration". This means that any
errors while reading `oauth_token` should be tolerated.
2020-04-23 15:41:37 +02:00
Mislav Marohnić
8ed9a0324e Merge remote-tracking branch 'origin/master' into oauth-read-org 2020-04-23 15:35:35 +02:00
Corey Johnson
e68be52ed0 Use the correct field 2020-04-22 14:03:44 -07:00
Corey Johnson
4b2382c737 Merge branch 'heathy-helping' of https://github.com/cli/cli into heathy-helping 2020-04-22 14:02:09 -07:00
Corey Johnson
c9d5935ee3 move to use 2020-04-22 14:00:08 -07:00
Corey Johnson
4dff85d3c1 Merge remote-tracking branch 'origin/master' into heathy-helping 2020-04-22 13:56:53 -07:00
Corey Johnson
c064b07e6d Add quote 2020-04-22 13:51:35 -07:00
Corey Johnson
0d79257312
use backets
Co-Authored-By: Amanda Pinsker <ampinsk@github.com>
2020-04-22 13:50:52 -07:00
Corey Johnson
833f8b4f2c
Update command/root.go
Co-Authored-By: Amanda Pinsker <ampinsk@github.com>
2020-04-22 13:50:06 -07:00
Corey Johnson
6d20283a7a Move feedback to the bottom 2020-04-22 13:49:42 -07:00
Corey Johnson
b5299ef5d7
pointy brackets ftw
Co-Authored-By: Amanda Pinsker <ampinsk@github.com>
2020-04-22 13:46:51 -07:00
vilmibm
bec58ede98 respect ssh
this adds recognition of the git_protocol setting when:

- creating a repo
- cloning a repo
- forking a repo
- forking/pushing during pr create
- checking out a PR

additionally, it:

- consolidates remote adding to use AddRemote; this introduces a fetch
where there previously hadn't been one
- changes repo clone to accept an ssh url
- changes repo fork to accept an ssh url

i just added basic unit tests; adding new test cases for all of the
above scenarios seemed like diminishing returns.
2020-04-22 14:21:01 -05:00
Corey Johnson
a4429aae41 rearrange code 2020-04-22 10:00:33 -07:00
Corey Johnson
be51d095ea Separating core from non-core commands 2020-04-21 13:30:07 -07:00
vilmibm
d4dd4a68bf fix error handling 2020-04-21 11:25:23 -05:00
vilmibm
c4693077aa move config stuff to its own package 2020-04-20 13:57:16 -05:00
vilmibm
815f461e8b more strict erroring around missing user/token 2020-04-20 12:49:46 -05:00