Skip to content

Use absolute path when configuring gh as git credential#3075

Merged
mislav merged 2 commits intotrunkfrom
credential-helper-absolute
Mar 4, 2021
Merged

Use absolute path when configuring gh as git credential#3075
mislav merged 2 commits intotrunkfrom
credential-helper-absolute

Conversation

@mislav
Copy link
Contributor

@mislav mislav commented Mar 3, 2021

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'

Fixes #2995

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'
@mislav mislav requested a review from a team March 3, 2021 15:26
}
return currentBranch, nil
},
Executable: ghExecutable,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like adding the executable to the command factory!

@mislav mislav merged commit aa5cf6c into trunk Mar 4, 2021
@mislav mislav deleted the credential-helper-absolute branch March 4, 2021 12:51
@jhoneDoe993

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git credential helper error with Homebrew

4 participants