Commit graph

26 commits

Author SHA1 Message Date
William Martin
540bda1a6b Test git credentials are configured in LoginFlow 2024-05-17 14:31:21 +02:00
William Martin
ba1afa2c5d Add HelperConfig contract test and FakeHelperConfig 2024-05-17 14:16:14 +02:00
William Martin
37abb3ec96 Fix mistaken git installation error check 2024-05-16 14:38:51 +02:00
William Martin
187c5016f0 Comment the git credential flow 2024-05-16 13:39:42 +02:00
William Martin
818d4ba5b8 Remove unnecessary credential setup private method 2024-05-16 13:39:42 +02:00
William Martin
177cf7d35b Rename gitcredentials Configure to ConfigureOurs 2024-05-16 13:15:26 +02:00
William Martin
bd4ba5c39a Make gitcredential helper smarter 2024-05-16 13:15:26 +02:00
William Martin
af589aa2f3 Move fetching configured helper into gitcredentials 2024-05-16 12:39:11 +02:00
William Martin
a3d65e0dce Extract units for configuring and updating git credential helpers 2024-05-16 12:32:55 +02:00
Mislav Marohnić
ba028b9044 Fix setting up git credential helper on Windows 2022-11-02 15:53:26 +01:00
Sam Coe
4294ee14a1
revert revert 57fbe4f317 (#6474) 2022-10-20 12:17:20 +00:00
Sam Coe
2cefb9fa59
Fix pr create regression (#6472)
* Revert "Refactor to use new git client (#6447)"

This reverts commit 57fbe4f317.

* Fix pr create regression
2022-10-20 12:46:23 +03:00
Sam Coe
57fbe4f317
Refactor to use new git client (#6447) 2022-10-19 21:11:36 +03:00
Sam Coe
2944f7c3ab
Create git client (#6354) 2022-10-14 07:47:03 +00:00
vilmibm
8f3032af36 use Prompter in auth commands 2022-09-13 13:22:50 -07:00
vilmibm
f7d5c5f725 move prompter to own package 2022-07-26 16:41:13 -05:00
vilmibm
4afb567d06 WIP: survey wrapper 2022-07-26 14:39:38 -05:00
Mislav Marohnić
583af3e54c
Allow gh auth git-credential to authenticate GitHub Gist requests (#3064)
* Allow `gh auth git-credential` to authenticate GitHub Gist requests

When there are stored credentials for `example.com`, allow using them to
authenticate requests to `gist.example.com` as well.

* Fix writing out of credential config

* remove unneccessary function

* actually delete

Co-authored-by: nate smith <vilmibm@github.com>
2022-01-14 22:18:07 +00:00
Des Preston
94a640bd2a
Add auth setup-git for setting up gh as a git credential helper (#4246)
Adds a new command `gh auth setup-git [<hostname>]` that sets up git to
use the GitHub CLI as a credential helper.

The gist is that it runs these two git commands for each hostname the
user is authenticated with.

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

If a hostname flag is given, it'll setup GH CLI as a credential helper
for only that hostname.

If the user is not authenticated with any git hostnames, or the user is
not authenticated with the hostname given as a flag, it'll print an
error.

Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-12-02 16:38:34 +00:00
Mislav Marohnić
2c86e671f3 Enable gh auth login for github.localhost 2021-10-18 20:01:18 +02:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
21521b06b9 Check git presence during auth login only if it's going to be needed 2021-08-11 19:22:16 +02: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
Mislav Marohnić
1bd6d7b36c Extract parts of HTTPS-related setup shared between login and refresh 2021-02-04 18:36:42 +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ć
381e83e6e5 Extend git credential prompt to auth refresh 2020-12-07 20:01:16 +01:00