Commit graph

103 commits

Author SHA1 Message Date
Josef Šimánek
f2848fcdda
Update StateDir comment to mention XDG_STATE_HOME. 2021-12-16 20:07:33 +01:00
Sam Coe
f1fbfdf6d0
Fix up bug in RemoveEntry and add tests for config_map 2021-11-22 09:24:03 -08:00
Marwan Sulaiman
a3940020f9
Inherit API endpoint configuration from the Codespaces environment (#4723)
gh codespace commands now respect the following environment variables:

- GITHUB_SERVER_URL: typically "https://github.com"
- GITHUB_API_URL: typically "https://api.github.com"
- INTERNAL_VSCS_TARGET_URL: typically "https://online.visualstudio.com"
- GITHUB_TOKEN when CODESPACES is set, even if the host connecting to isn't "github.com".

This set of changes ensures that `gh codespace` commands automatically connect to the right API endpoints when gh is used within a codespace.

Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-11-22 12:40:01 +01:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Sam
8fb6bb66c8
Merge pull request #3992 from despreston/858-config-browser
add browser option to config
2021-08-17 14:17:54 -07:00
Sam Coe
315c6e4eb7
Remove backwards compatibility with homedir library for config files 2021-08-17 10:28:16 -07:00
Sam Coe
34b3d5bb86
Add tests and a little polish 2021-08-17 10:05:54 -07:00
Mislav Marohnić
aec0f10041 Fix error message when using GH_ENTERPRISE_TOKEN but host is ambiguous
Before:

    $ GH_ENTERPRISE_TOKEN="..." gh pr create
    could not find hosts config: not found

Now:

    $ GH_ENTERPRISE_TOKEN="..." gh pr create
    set the GH_HOST environment variable to specify which GitHub host to use

Also amends `gh help environment` documentation to suggest the use of
GH_HOST when scripting operations with GitHub Enterprise repositories.
2021-07-20 14:11:07 +02:00
Mislav Marohnić
25b6eecc8d
Merge pull request #4017 from despreston/des/avoid-migrate
Skip auto migrate of config when GH_CONFIG_DIR
2021-07-20 13:33:16 +02:00
Des Preston
1c9b4bf99d Skip auto migrate of config when GH_CONFIG_DIR
If GH_CONFIG_DIR is set, don't auto migrate the config file. This fixes
the situation where the path given via GH_CONFIG_DIR does not exist and
the cli attempts to migrate an existing config to that location.

Fixes #3837
2021-07-19 16:33:51 -04:00
Des Preston
c95f30af80 add browser option to config
Allows setting the path to the browser using the config.

Closes #858
2021-07-13 15:07:57 -04:00
Sam Coe
b514d22f1e
Fix issue in FindEntry that causes extensions and alias crash 2021-06-29 15:01:00 -07:00
jonathan gold
5f162561ac Add config handling for http_unix_socket 2021-06-25 11:47:22 -07:00
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
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
9ec1e21d4c
Default to GHES host if only GHES is authenticated (#3286) 2021-03-30 16:51:00 +02: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ć
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ć
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
Cristian Dominguez
3afb1d0b1a Use Testify assertions in test 2021-01-16 19:19:30 -03: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
c8b9486fd3 spelling: nonexistent 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
Sam Coe
ce18b943b8
Export type ConfigOption and group InvalidValueError code 2020-11-03 09:49:05 +03:00
Sam Coe
5c5f52c4c4
Refactor config command 2020-11-03 09:49:05 +03:00
Sam Coe
e6be06f737
Cleanup duplicate config options 2020-11-03 09:49:05 +03:00
Mislav Marohnić
ae7d42a876 Centralize all known configuration options 2020-10-26 14:42:04 +01:00
Shrihan Kumar Padhy
f31e49fdff
Add a new config validation key called prompt (#2246) 2020-10-21 16:56:25 +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
yuuji.yaginuma
177f683876 Fix typo overriden -> overridden 2020-09-18 13:59:44 +09: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