Commit graph

90 commits

Author SHA1 Message Date
Mislav Marohnić
ae7d42a876 Centralize all known configuration options 2020-10-26 14:42:04 +01:00
Sam
d7d5a6b753
Merge pull request #2247 from cli/refactor-command-root
Change command package to be build package
2020-10-22 10:50:15 +02:00
Mislav Marohnić
460d55f723 Move HostnameValidator to ghinstance 2020-10-21 16:31:20 +00:00
Shrihan Kumar Padhy
f31e49fdff
Add a new config validation key called prompt (#2246) 2020-10-21 16:56:25 +02:00
Sam Coe
f0b534f92e
Move build to internal 2020-10-21 13:31:32 +02:00
Mislav Marohnić
14a222bade Let the receiver choose how to format the cfg.Set() value error 2020-10-16 18:54:36 +00:00
Cristian Dominguez
09401b30b6 Validate git protocol config before setting it 2020-10-16 18:54:25 +00:00
Teubel György
9b2fe1ee30 Disable pager when set to "cat" 2020-09-29 23:21:59 +02:00
Mislav Marohnić
f9783fe812 Add exec.Command stub mechanism that matches by arguments
Our previous command stub mechanism matches stubs sequentially, which leads to brittle tests when the exec calls get reordered or removed in the implementation.
2020-09-23 18:38:29 +02:00
yuuji.yaginuma
177f683876 Fix typo overriden -> overridden 2020-09-18 13:59:44 +09:00
Nate Smith
bdadb3058b
Merge pull request #1699 from cli/more-gists
bunch of gist stuff
2020-09-16 11:36:54 -05:00
Mislav Marohnić
f6dd1bcd0a Add the pager config option 2020-09-16 16:15:37 +02:00
Mislav Marohnić
c643778701 Have only one test assert default config rendering 2020-09-16 16:10:53 +02:00
vilmibm
dc345a9f73 support --web for gist view 2020-09-14 10:33:29 -05:00
vilmibm
1073c97409 review feedback 2020-09-11 11:36:24 -05:00
vilmibm
79b5ca2cd6 update default config test values 2020-09-10 12:13:48 -05:00
vilmibm
15bfb5447b split auth flow code into new internal package 2020-09-10 12:13:48 -05:00
vilmibm
ecd1b34b39 Add prompt config setting and support in CanPrompt 2020-09-10 12:13:48 -05:00
Mislav Marohnić
c80292c2e8 Extend Config object with GITHUB_TOKEN support
Adding GITHUB_TOKEN & GITHUB_ENTERPRISE_TOKEN support orthogonal to
Config was getting out of hand, especially in `auth` commands that
adjust their messaging and error status based on the presence of these
environment variables.

The new approach builds in support for tokens from environment straight
into Config object by composition. Thus, commands need not ever be
concerned with any specific environment variables.
2020-09-07 21:33:26 +02:00
Mislav Marohnić
a8b06c329b Ensure correct ANSI color output during OAuth flow on Windows
We used to write directly to `os.Stderr`, but we first need to convert
that into a colorable stream.
2020-09-01 12:31:36 +02:00
Nate Smith
e8c4b301d3
Merge pull request #1522 from cli/oauth-device-flow
Implement OAuth Device Authorization flow
2020-08-25 13:54:07 -05:00
Mislav Marohnić
d8c5b7bfc0
Merge pull request #1517 from cli/select-host
Allow explicitly setting hostname for gh operations
2020-08-14 19:08:13 +02:00
Mislav Marohnić
60eebd2896 Implement OAuth Device Authorization flow
Before, we implemented the OAuth app authorization flow which requires a
callback URL. To provide such a URL, we had to spin up a local HTTP
server, which was brittle and did not cover cases where a person might
want to authenticate with a browser that runs on a different machine
than the GitHub CLI process.

This implements the OAuth Device Authorization flow where the user is
given a one-time code and asked to paste it in the browser flow. There
is no callback URL, so we can avoid spinning up a local server, and the
user may open a browser on any of their devices, as long as they provide
the correct one-time code.

If the Device Authorization flow is detected to be unavailable for the
OAuth app (right now, it's specifically enabled for GitHub CLI) or for
an older GitHub Enterprise instance, this falls back to the old app
authentication flow.
2020-08-13 19:21:08 +02:00
vilmibm
e6ae0a122b accept additional scopes in auth flow 2020-08-12 12:05:54 -05:00
Mislav Marohnić
c095a4bead Allow explicitly specifying the hostname for gh operations
Accept the "HOST/OWNER/REPO" syntax or passing a full URL for both the
`--repo` flag and the GH_REPO environment variable and allow setting
GH_HOST environment variable to override just the hostname for
operations that assume "github.com" by default.

Examples:

    $ gh repo clone example.org/owner/repo
    $ GH_HOST=example.org gh repo clone repo

    $ GH_HOST=example.org gh api user
    $ GH_HOST=example.org gh gist create myfile.txt

    $ gh issue list -R example.org/owner/repo
    $ gh issue list -R https://example.org/owner/repo.git
    $ GH_REPO=example.org/owner/repo gh issue list
2020-08-12 16:16:34 +02:00
Mislav Marohnić
7908c214df Avoid erroring when looking up config keys for nonexistent host 2020-08-12 15:33:26 +02:00
Mislav Marohnić
a6e78d74de Merge branch 'pr-commands-isolate-3' into issue-commands-isolate 2020-08-11 15:40:05 +02:00
Mislav Marohnić
172ea2b078 Isolate all alias commands 2020-08-11 13:57:48 +02:00
vilmibm
2e7511cd18 add helpers to config type for hosts 2020-08-06 12:50:01 -05:00
vilmibm
35f18b6c02 gh auth login 2020-08-06 12:43:35 -05:00
Mislav Marohnić
87632791d6 Add ghinstance tests 2020-07-27 20:09:57 +02:00
Mislav Marohnić
0cbcf8a7fa Merge remote-tracking branch 'origin' into ghe-api 2020-07-27 16:30:20 +02:00
vilmibm
1831d95433 isolated clone command
This commit hacks the existing repo clone tests into something usable by
the new isolated command. It went ok and was less effort than trying to
introduce the same kind of test format as repo view and gist create.
2020-07-23 16:40:31 -05:00
Mislav Marohnić
288d01318b Respect the hostname of current repository in queries 2020-07-23 22:31:08 +02:00
vilmibm
dc02366128 move generateRepoURL to ghrepo 2020-07-23 11:16:47 -05:00
Mislav Marohnić
87a9dc8d4b Merge remote-tracking branch 'origin' into ghe-remotes 2020-07-13 13:39:14 +02:00
Mislav Marohnić
b30cf15094
Merge pull request #1295 from cli/path-error
Raise more informative path error when reading config file
2020-07-10 13:25:34 +02:00
Mislav Marohnić
446a4111f7 Respect hostnames when resolving git remotes and URL args to repos 2020-07-02 20:36:10 +02:00
Mislav Marohnić
569645a050 Support hosts.yml existing while config.yml does not
After a person copies `hosts.yml` to a headless system, they will still
be forced to go through re-authentication flow unless they copy or
initialize a `config.yml` as well. This fixes respecting authentication
info from `hosts.yml` even if `config.yml` is missing.
2020-07-01 14:34:44 +02:00
Mislav Marohnić
4827ffbf03 Raise more informative path error when reading config file
Example:

    remove or rename regular file `/home/foo/.config/gh` (must be a directory)
2020-06-30 13:47:15 +02:00
Mislav Marohnić
3ea71e6eb6 Add ability to parse non-GitHub.com git remotes 2020-06-23 19:51:26 +02:00
vilmibm
64a7fd4200 test default configuration 2020-06-11 14:04:41 -05:00
vilmibm
47102fe427 just fill in the blank config with default content 2020-06-11 14:04:29 -05:00
vilmibm
cabf0b1972 populate initial config 2020-06-10 17:08:12 -05:00
vilmibm
8963d80942 better get func 2020-06-05 13:09:04 -05:00
vilmibm
6bd898ee54 start on alias delete 2020-06-05 13:04:45 -05:00
vilmibm
106a0957e1 review feedback 2020-06-05 12:24:54 -05:00
vilmibm
a05daf2145 gh alias list 2020-06-05 12:06:51 -05:00
Mislav Marohnić
9a5b628001 Ensure consistent order of yaml keys in migrateConfig 2020-06-04 12:22:26 +02:00
Mislav Marohnić
1f616859fc Merge remote-tracking branch 'origin' into auth-split 2020-06-04 12:00:19 +02:00