New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where keychain github credentials wouldn't work #3376

Merged
merged 1 commit into from Oct 29, 2017

Conversation

Projects
None yet
2 participants
@tomjonandy
Contributor

tomjonandy commented Oct 26, 2017

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example. N/A
  • Have you successfully run brew tests with your changes locally?

This fixes #3363

I would also suggest that lines 32-52 of Library/Homebrew/utils/github.rb be rewritten to use :environment and :keychain rather than re-reading the environment variable (as this would have avoided some of the confusion that this bug caused), although I could be missing something that would mean this wouldn't work. (I would be happy to either add that change to this this pull request or create a new one for the purpose as you see fit).

@MikeMcQuaid

This comment has been minimized.

Show comment
Hide comment
@MikeMcQuaid

MikeMcQuaid Oct 27, 2017

Member

If I'm understanding this correctly: this will always prefer the environment variable over the keychain if both are set, right? That seems reasonable to me but I'm just checking it is what I think it is.

Member

MikeMcQuaid commented Oct 27, 2017

If I'm understanding this correctly: this will always prefer the environment variable over the keychain if both are set, right? That seems reasonable to me but I'm just checking it is what I think it is.

@tomjonandy

This comment has been minimized.

Show comment
Hide comment
@tomjonandy

tomjonandy Oct 27, 2017

Contributor

That was always the case anyway (see the if block in function api_credentials, lines 54 - 71 of Library/Homebrew/utils/github.rb), this fixes a bug where if there was just one thing returned from api_credentials (meaning it is a personal access token, see line 57 of the same file) api_credentials_type was set as :keychain. If it returned 2 things (meaning it is a username and password) it was set as :environent, when those tokens should have been the other way around. This meant that if someone isn't using a personal access token, but has git credentials in keychain, it was treating the password from those credentials as a personal access token, which obviously doesn't work.

Contributor

tomjonandy commented Oct 27, 2017

That was always the case anyway (see the if block in function api_credentials, lines 54 - 71 of Library/Homebrew/utils/github.rb), this fixes a bug where if there was just one thing returned from api_credentials (meaning it is a personal access token, see line 57 of the same file) api_credentials_type was set as :keychain. If it returned 2 things (meaning it is a username and password) it was set as :environent, when those tokens should have been the other way around. This meant that if someone isn't using a personal access token, but has git credentials in keychain, it was treating the password from those credentials as a personal access token, which obviously doesn't work.

@MikeMcQuaid MikeMcQuaid merged commit c59c0d6 into Homebrew:master Oct 29, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@MikeMcQuaid

This comment has been minimized.

Show comment
Hide comment
@MikeMcQuaid

MikeMcQuaid Oct 29, 2017

Member

Thanks for your great first contribution to Homebrew, @tomjonandy! Without people like you submitting PRs we couldn't run this project. You rock!

Member

MikeMcQuaid commented Oct 29, 2017

Thanks for your great first contribution to Homebrew, @tomjonandy! Without people like you submitting PRs we couldn't run this project. You rock!

@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018

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