feat: implement heroku git:credentials as a git credential helper#3683
Merged
erika-wallace merged 3 commits intofeat/credential-mgr-integrationfrom Apr 29, 2026
Merged
feat: implement heroku git:credentials as a git credential helper#3683erika-wallace merged 3 commits intofeat/credential-mgr-integrationfrom
erika-wallace merged 3 commits intofeat/credential-mgr-integrationfrom
Conversation
781e99e
into
feat/credential-mgr-integration
33 of 34 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements
heroku git:credentialsas a git credential helper for Heroku Git authentication.When git needs credentials for git.heroku.com, it will call
heroku git:credentials get, which reads the stored Heroku auth token and outputs it in the format git expects.Changes:
src/commands/git/credentials.tssrc/lib/git/git.tsconfigureCredentialHelper(), which writes!heroku git:credentialsas a URL-scoped global git credential helper. Since the helper starts with!, Git executes it as a shell command.ux.error()with try/catch in spawn's error handler to route errors through the Promise rejection channelsrc/commands/auth/login.tsconfigureCredentialHelper()after successful login; silently ignores errorssrc/commands/apps/create.ts,src/commands/git/clone.ts,src/commands/git/remote.tsconfigureCredentialHelper()after git operations to handle the case where git was not installed whenheroku loginwas runTests:
git:credentialscovering protocol operations and host validationapps:create,git:remote, andgit:cloneauth:logincovering login validation and git credential helper configurationcredentialManagerStubto allow custom return values per testtest/unit/lib/git/git.unit.test.ts; madeexecFilePromiseaccessible as an instance property to properly stubcp.execFileafter promisifyNote on git unit tests: The git commands are not well tested, tracked in W-13589124. This PR fixes the skipped tests and adds coverage for the new functionality. Remaining improvements are tracked in that work item.
Type of Change
Breaking Changes (major semver update)
!after your change type to denote a change that breaks current behaviorFeature Additions (minor semver update)
Patch Updates (patch semver update)
Testing
Notes:
You need access to a Heroku app with a git remote for testing
git push heroku main. The test steps will temporarily replace your installed Heroku CLI with the local build and modify your global git config — both are restored in the cleanup steps.Steps:
heroku logoutnpm install && npm run buildnpm link— replaces the installed version of Heroku with this local buildwhich heroku— confirm it shows a local/npm path rather than homebrewheroku logingit config --global credential.https://git.heroku.com.helper— should return!heroku git:credentials~/.netrcand remove any lines forgit.heroku.com— this forces git to use the credential helper instead of netrc directlycdinto a local app directory with a Heroku remoteGIT_TRACE=1 git push heroku main— in the trace output, confirm you seerun_command: 'heroku git:credentials get'near the start of authenticationCleanup:
13.
heroku logout14.
npm unlink -g heroku15.
which heroku— confirm the original Heroku path is restored16.
git config --unset --global credential.https://git.heroku.com.helper17.
heroku login— re-authenticates and writes fresh credentials to ~/.netrcScreenshots (if applicable)
Related Issues
GUS work item: W-22182925