Commit graph

25 commits

Author SHA1 Message Date
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
Mislav Marohnić
4315c09501 Ignore non-pre-authenticated hosts when parsing git remotes
This ensures that while having git remotes to point to either
`github.com` or authenticated GHE instances, adding another git remote
pointing to an unrelated host won't change the remote resolution in any
way, even if the unrelated remote is called `upstream` or `github` (and
thus normally took precedence).
2020-08-12 18:13:05 +02:00
Mislav Marohnić
aef1a4ba4d Extract root command and factory logic into separate packages 2020-08-07 14:40:33 +02:00