Commit graph

52 commits

Author SHA1 Message Date
Mislav Marohnić
66c18b40f2
Handle SAML enforcement challenge from the server (#5054)
Whenever a SSO challenge gets issued by the server by means of a URL in
the `X-GitHub-SSO` response header, gh now additionally prints that URL
on the standard error stream.

This is achieved by installing a middleware to all HTTP requests and
storing the server challenge to a value accessible by `factory.SSOURL()`.
Such approach was made necessary mainly because of the
`shurcool-graphql` client which doesn't give access to response headers
when a GraphQL error case is encountered.
2022-01-19 14:22:22 +01:00
Nate Smith
4b415f80d7
Merge pull request #5022 from cli/config-defaults
add GetOrDefault and related methods to Config
2022-01-17 10:44:28 -06:00
nate smith
0a619d422a undo overzealous find/replace 2022-01-14 15:27:05 -06:00
nate smith
56522f9f14 formatting 2022-01-11 14:57:10 -06:00
nate smith
562f1b3d0d add GetOrDefault functionality to config 2022-01-11 14:56:58 -06:00
Mislav Marohnić
3cce16e72d Refactor factory.Executable() to be a method rather than a func
This way, factory can satisfy an interface that requires `Executable()`.
2021-12-21 13:50:55 +01:00
Mislav Marohnić
d853ce5bc9 Avoid resolving executable() until requested at runtime
This is to avoid hitting the filesystem and resolving symlinks
unnecessarily. The value of executable is just used conditionally by a
handful of commands.
2021-09-24 14:42:41 +02:00
Mislav Marohnić
78b35b7b6e Merge remote-tracking branch 'origin' into 3704-credential-helper 2021-09-24 14:35:01 +02:00
vilmibm
7bf85355a9 restore cached client 2021-09-22 15:59:57 -05:00
vilmibm
514d4d992c refactor dependencies of ext manager 2021-09-21 15:55:31 -05:00
Mislav Marohnić
d731cb9c73 Fix determining current process location 2021-09-06 16:57:59 +02:00
Mislav Marohnić
55c3064f45 Merge remote-tracking branch 'origin' into 3704-credential-helper 2021-09-06 16:16:52 +02:00
wilso199
2dba58bfa8 Using gh executable from PATH in favor of the resolved path 2021-08-30 16:57:43 -04: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
a07748f1f1
Add support for GH_BROWSER env var 2021-08-17 14:07:49 -07:00
Sam Coe
34b3d5bb86
Add tests and a little polish 2021-08-17 10:05:54 -07:00
Mislav Marohnić
bf9c49eccd Rename gh extensionsgh extension
This is for compatibility with other core commands which are all singular.
2021-08-11 22:22:39 +02:00
Mislav Marohnić
82c6fb7d1a Add a note about the dummy GHE hostname 2021-07-26 18:59:53 +02: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
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
vilmibm
202168ee8d add nebula preview 2021-06-30 17:38:07 -05:00
Nate Smith
554250bc4e
Merge pull request #3779 from jgold-stripe/unix
Add ability to dial API via unix socket
2021-06-29 09:46:33 -07:00
jonathan gold
666ed2f3d9 Apply value of http_unix_socket if present in config 2021-06-25 11:47:24 -07:00
jonathan gold
fc3dec4a58 Change signature of NewHTTPClient to accomodate errors 2021-06-25 11:26:21 -07:00
Mislav Marohnić
1ec47d8191 Improvements to gh extensions
- Extensions on Windows now enabled through the `sh.exe` interpreter
- `sh.exe` now found on Windows when git was installed via scoop
- `gh extensions list` command shows origin repo for the extension
- `gh extensions upgrade --all` is required to upgrade all extensions
- Added `gh extensions remove`
- Shell completions now include aliases and extension names
- `gh` help output now lists available extension names
- Extensions are stored to XDG_DATA_HOME
2021-06-21 16:54:08 +02:00
Mislav Marohnić
4b2cded1f8 Ensure that tests for command factory never read from user's config
If these tests are going to exerise `factory.New()`, the config getter
should always be overriden since the default config getter reads from
`~/.config/gh` and thus makes tests dependent on the user's environment.
2021-06-17 17:59:34 +02:00
Sam Coe
edfac42384
Set up iostreams in factory default 2021-06-15 09:20:00 -04:00
Sam Coe
53fac59ef9
Cleanup factory/default and add tests 2021-06-15 09:19:16 -04:00
Mislav Marohnić
4debbb17cd Further separate out test cases 2021-06-11 14:32:08 +02:00
Mislav Marohnić
3a55c26000 Update "Accept" header for github.com requests
The `antiope-preview` has graduated in github.com and no longer needs
activating. However, we still need it for GHES requests.
2021-06-08 19:25:40 +02:00
Mislav Marohnić
8a221bb766 Add tests for our default HTTP client 2021-06-08 19:21:48 +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ć
98f1f5ec0d Use absolute path when configuring gh as git credential
This keeps git operations working even when PATH is modified, e.g. `brew
update` will work even though Homebrew runs the command explicitly
without `/usr/local/bin` in PATH.

Additionally, this inserts a blank value for `credential.*.helper` to
instruct git to ignore previously configured credential helpers, i.e.
those that might have been set up in system configuration files. We do
this because otherwise, git will store the credential obtained from gh
in every other credential helper in the chain, which we want to avoid.

Before:

    git config --global credential.https://github.com.helper '!gh auth git-credential'

After:

    git config --global credential.https://github.com.helper ''
    git config --global --add credential.https://github.com.helper '!/path/to/gh auth git-credential'
2021-03-03 16:20:21 +01:00
vilmibm
57140ad35e add header in correct place 2021-02-16 12:25:09 -06:00
Cristian Dominguez
2086d135f3
Respect system/user timezone in API requests (#2630)
* Respect system/user timezone in API requests

* Fall back to a known timezone if TZ is not set

Co-authored-by: Cristian Dominguez <cristiand391@users.noreply.github.com>
2021-01-20 10:44:46 -08:00
Nate Smith
c7eb57d443
respect GH_HOST when resolving remotes (#2301)
* vim to gitignore

* respect GH_HOST in Resolver

* slight restructure, add a test

* grammar fix
2020-11-19 12:59:18 -06:00
Mislav Marohnić
662f83fcb9 Fix release download
Only ever try to set an `Authorization` request header to hosts that we
have OAuth credentials for; skip the header otherwise.
2020-09-14 15:31:31 +02: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ć
feadf684fb Merge remote-tracking branch 'origin' into ghe-auth-tweaks 2020-09-07 17:37:16 +02:00
Mislav Marohnić
995828abf8 Avoid setting a default Accept header in hub api
Due to our HTTP client default behavior, an `Accept` header is added to
all API requests. This is fine for all commands except `gh api`, where
the user should ideally have fine-grained control over most aspects of
HTTP requests and where there should be little to no defaults in general.
2020-09-04 17:42:57 +02:00
Mislav Marohnić
2bb5e052d8 Send GITHUB_TOKEN to github.com and GITHUB_ENTERPRISE_TOKEN to GHES 2020-09-04 17:25:37 +02:00
vilmibm
cba401deb0 check parent annotatiosn for auth skip 2020-08-19 10:21:19 -05:00
vilmibm
621f6a262b minor 2020-08-19 10:11:16 -05:00
vilmibm
b1a6346e07 take out auto browser flow 2020-08-18 17:57:52 -05:00
vilmibm
ff9ecd2944 CTA for ghes remote auth case 2020-08-18 17:57:52 -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
vilmibm
1efd3ebb51 rebase strife 2020-08-12 12:07:36 -05:00