Commit graph

157 commits

Author SHA1 Message Date
Sam Coe
e6ad8a10d0
Add support for XDG_DATA_HOME 2021-06-02 09:46:14 -04:00
Sam Coe
1d7ffc2013
Add support for LocalAppData and .local/state/ fallback 2021-06-01 15:50:10 -04:00
Sam Coe
602167c0c7
Address PR comments 2021-05-26 11:28:58 -04:00
Sam Coe
583e74d70c
Add support for XDG_STATE_HOME 2021-05-25 16:30:51 -04:00
Sam Coe
972d5ff5f0
Fix test that was deleting local config folder 2021-05-24 18:35:37 -04:00
Sam Coe
0d49bfba42
Add support for XDG_CONFIG_HOME and AppData on Windows 2021-05-24 16:13:33 -04:00
Mislav Marohnić
e0e25c82ff Fix creating Windows directory for gh config 2021-05-19 17:13:12 +02:00
Cristian Dominguez
2f94adabb2
Use T.TempDir for temporary dirs in tests (#3580) 2021-05-07 12:21:26 +02:00
Mislav Marohnić
c57e30fff0 Fix stubbing config in tests on Windows 2021-04-22 11:42:51 +02:00
Mislav Marohnić
c6c3e72f43 Unexport StubConfig 2021-04-22 11:42:28 +02:00
Junjie Yuan
927e4c7e4d
using filepath.Join() instead of path.Join() to fix wrong filepath on Windows:
PS C:\Users\Junjie Yuan> gh auth status
github.com
  ✓ Logged in to github.com as junjieyuan (C:\Users\Junjie Yuan\.config\gh/hosts.yml)
  ✓ Git operations for github.com configured to use https protocol.
  ✓ Token: *******************

Signed-off-by: Junjie Yuan <yuan@junjie.pro>
2021-04-22 15:19:16 +08:00
Sam Coe
ee687d7e7f
Add tests for quick fix 2021-04-02 08:42:19 -07:00
Mislav Marohnić
69ca2dda4a Quick fix: respect default hostname when parsing owner/repo pairs
This re-enables using GH_HOST to set a default hostname when
supplying repo argument like `gh repo clone owner/repo`.
2021-04-02 15:16:27 +02:00
Mislav Marohnić
44ae7ae3cf
Merge pull request #3279 from cli/browser-refactor
Pass web browser to each individual command
2021-03-30 16:54:59 +02:00
Sam
9ec1e21d4c
Default to GHES host if only GHES is authenticated (#3286) 2021-03-30 16:51:00 +02:00
Mislav Marohnić
111e8dbcf2 Pass web browser to each individual command
This removes sensitivity to the BROWSER environment variable in tests
and makes it easier to verify the URL that the browser was invoked with
without having to stub sub-processes.
2021-03-19 21:22:37 +01:00
Mislav Marohnić
4cd43cc8ef Merge remote-tracking branch 'origin' into auth-with-ssh 2021-02-17 15:29:36 +01:00
Mislav Marohnić
feb4acc2c0 Suggest brew upgrade gh when new version detected
When the update notifier is enabled and a new version was detected, show
a Homebrew upgrade notice if:
- the release was at least 24 hours ago; and
- the current `gh` binary is under the Homebrew prefix.
2021-02-08 13:57:08 +01:00
Mislav Marohnić
075b6f8aa6 Remove workflow from default OAuth scopes
We now request it conditionally only for "HTTPS" login flow
2021-02-04 17:40:09 +01:00
Mislav Marohnić
5a110c8e42 Add SSH key generation & uploading to gh auth login flow 2021-02-01 23:34:00 +01:00
Mislav Marohnić
d86cfe4627 Unpublish SetPrepareCmd 2021-01-28 21:59:30 +01:00
Sam Coe
85a6267810
Remove last hardcoded config paths and fix tests 2021-01-25 11:43:37 -08:00
Kevin McDermott
d54a7618d4
Configuration path can come from environment.
This adds support for using the GH_CONFIG_DIR environment variable to determine
where the config files are written, this is useful for cases where the homedir
is not writable.
2021-01-25 10:07:54 -08:00
Mislav Marohnić
64fda21116 Avoid ever invoking go-homedir when config was found in a new location 2021-01-22 20:22:32 +01:00
Matthew Gleich
7d9461b819 ♻️ Refactor to use os.UserHomeDir() 2021-01-22 18:51:28 +01:00
Mislav Marohnić
06cf2c9f81 Merge remote-tracking branch 'origin' into cmd-stub-new 2021-01-22 16:31:29 +01:00
Mislav Marohnić
f1a9da40a4
Merge pull request #2812 from cli/updater-dev-version-match
Update notifier: avoid false positives when gh is built from source
2021-01-21 15:11:23 +01:00
Mislav Marohnić
c9407b2629 More descriptive error when aborting auth due to environment variables
Old message:

    read-only token in GH_TOKEN cannot be modified

This message was vague and some users did not understand that this
refers to the value that is read from environment variables.

New message:

    $ GH_TOKEN=123 ghd auth login -h github.com
    The value of the GH_TOKEN environment variable is being used for authentication.
    To have GitHub CLI store credentials instead, first clear the value from the environment.
2021-01-20 18:27:35 +01:00
Mislav Marohnić
82d19b73d6 Update notifier: avoid false positives when gh is built from source
When gh was built from source, the version number will look something
like this since it's taken from `git describe`:

    v1.4.0-34-g{SHA}

When compared as semver against `v1.4.0`, the latter version is falsely
reported as newer. This is because the output of `git describe` wasn't
meant to be interpreted as semver.

The solution is to translate the `git describe` string to faux-semver so
it can be safely compared with the version reported from the server.

Fixes this case:

    A new release of gh is available: v1.4.0-41-g2f9e4cb1 → v1.4.0
    https://github.com/cli/cli/releases/tag/v1.4.0
2021-01-20 16:13:50 +01:00
Mislav Marohnić
75ebb863e3 Use testify assertions for error matching 2021-01-19 13:59:37 +01:00
Cristian Dominguez
45f4a1f087 Equal: flip arguments position 2021-01-18 21:00:59 -03:00
Mislav Marohnić
c308f1cd91 Prevent further use of SetPrepareCmd and InitCmdStubber 2021-01-18 22:44:53 +01:00
Cristian Dominguez
3afb1d0b1a Use Testify assertions in test 2021-01-16 19:19:30 -03:00
Cristian Dominguez
ce151420f3 Migrate legacy tests 2021-01-11 21:07:19 -03:00
Mislav Marohnić
536a173364 Enable debugging HTTP traffic during auth login/refresh 2021-01-05 16:24:47 +01:00
Mislav Marohnić
9140e88708 Extract oauth package 2020-12-18 20:27:56 +01:00
Mislav Marohnić
d81b2927a5
Merge pull request #2488 from cristiand391/new-release-notification
Notify new releases only once per day
2020-12-15 16:15:01 +01:00
Mislav Marohnić
2843ffff23 Classify the update package as internal 2020-12-15 16:09:08 +01:00
Mislav Marohnić
ada59236c6 Add workflow to the list of default OAuth scopes we request
Since GitHub CLI now offers to authenticate your Git as well, the token
we request here will be used for git pushes. Since we do anticipate our
users making edits to their GitHub Actions workflow files, we want them
to be able to push their changes, and this scope allows that.
2020-12-07 20:12:58 +01:00
Mislav Marohnić
bc81282a6c Merge remote-tracking branch 'origin' into git-credentials 2020-12-07 20:02:08 +01:00
Sam Coe
e21c5100fa
Properly check env auth tokens in CheckAuth 2020-12-01 11:44:14 -05:00
Mislav Marohnić
d56d92c908 If git credential helper is non-defined, set gh as credential helper 2020-11-23 20:20:05 +01:00
Josh Soref
a66a65d422 spelling: unmatched 2020-11-21 21:43:51 -05:00
Josh Soref
c8b9486fd3 spelling: nonexistent 2020-11-21 21:43:51 -05:00
Josh Soref
8ba68fc68a spelling: deprecated 2020-11-21 21:43:51 -05:00
Sam Coe
2eb40f8a14
Empty auth token env variables are equal to being unset 2020-11-12 10:09:08 +03:00
Sam Coe
414de332fb
cleanup 2020-11-12 09:52:14 +03:00
Sam Coe
a79a0bbfd7
Add support for GH_TOKEN and GH_ENTERPRISE_TOKEN 2020-11-12 09:52:10 +03:00
Mislav Marohnić
6e1e62f496 Consistently print commands in DEBUG mode 2020-11-11 18:17:01 +01:00
Mislav Marohnić
97b176da93 Fix git executable name for Windows in tests 2020-11-11 16:46:49 +01:00