diff --git a/lib/util/git/auth.spec.ts b/lib/util/git/auth.spec.ts index 7e54bf89aa50b101fcc2da6b8ada29001cec5629..6e3d5690a8a7463f61c9c9b193a5f6e26f039aff 100644 --- a/lib/util/git/auth.spec.ts +++ b/lib/util/git/auth.spec.ts @@ -18,14 +18,15 @@ describe('util/git/auth', () => { }); }); - it('returns url with correctly encoded token', () => { + it('returns correct url if token already contains GitHub App username', () => { expect( getGitAuthenticatedEnvironmentVariables( 'https://github.com/', - 'token:1234' + 'x-access-token:token1234' ) ).toStrictEqual({ - GIT_CONFIG_KEY_0: 'url.https://token%3A1234@github.com/.insteadOf', + GIT_CONFIG_KEY_0: + 'url.https://x-access-token:token1234@github.com/.insteadOf', GIT_CONFIG_VALUE_0: 'https://github.com/', GIT_CONFIG_COUNT: '1', }); diff --git a/lib/util/git/auth.ts b/lib/util/git/auth.ts index 3a6c56b2185fb63d41b999052203e461a67d25be..fd5dd855ab1e9c127b160a2384216fccea731ddb 100644 --- a/lib/util/git/auth.ts +++ b/lib/util/git/auth.ts @@ -24,7 +24,7 @@ export function getGitAuthenticatedEnvironmentVariables( } } - const gitUrlWithToken = getHttpUrl(gitUrl, encodeURIComponent(token)); + const gitUrlWithToken = getHttpUrl(gitUrl, token); // create a shallow copy of the environmentVariables as base so we don't modify the input parameter object // add the two new config key and value to the returnEnvironmentVariables object