From c0ff0ef2c14f174275748bdc500f33269fc7b5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Marchand?= Date: Tue, 14 Sep 2021 10:59:40 +0000 Subject: [PATCH 1/5] Don't overwrite user if it already include token --- lib/util/git/url.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/util/git/url.ts b/lib/util/git/url.ts index 881de8722b3c6f..0f9066ed16d1a2 100644 --- a/lib/util/git/url.ts +++ b/lib/util/git/url.ts @@ -5,7 +5,11 @@ import * as hostRules from '../host-rules'; export function getHttpUrl(url: string, token?: string): string { const parsedUrl = GitUrlParse(url); - parsedUrl.token = token; + if (parsedUrl.user.includes(token)) { + parsedUrl.token = parsedUrl.user; + } else { + parsedUrl.token = token; + } const protocol = /^https?$/.exec(parsedUrl.protocol) ? parsedUrl.protocol From d750e0f79d7dd23a4658dee417e54e2424a5acdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Marchand?= Date: Tue, 14 Sep 2021 12:05:39 +0000 Subject: [PATCH 2/5] Add URL test --- lib/util/git/url.spec.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/util/git/url.spec.ts b/lib/util/git/url.spec.ts index eceb04c32c2cbe..0995356d5d9059 100644 --- a/lib/util/git/url.spec.ts +++ b/lib/util/git/url.spec.ts @@ -39,6 +39,13 @@ describe('util/git/url', () => { ); }); + it('returns https url with token with included username', () => { + hostRules.find.mockReturnValueOnce({ token: 'token' }); + expect( + getRemoteUrlWithToken('https://oauth2:token@foo.bar/bar/foo') + ).toBe('https://oauth2:token@foo.bar/bar/foo'); + }); + it('returns https url with token for non-http protocols', () => { hostRules.find.mockReturnValueOnce({ token: 'token' }); expect(getRemoteUrlWithToken('ssh://foo.bar/')).toBe( From 3c58d0db7f73c9f29f21383bd15c62f32d493783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Marchand?= Date: Tue, 14 Sep 2021 12:05:53 +0000 Subject: [PATCH 3/5] Fix jest cli arguments --- .vscode/launch.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index cedef1459c4c08..6989fa435d125d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -22,7 +22,7 @@ "args": [ "--runInBand", "--collectCoverage=false", - "--testTimeout 100000000", + "--testTimeout=100000000", "--runTestsByPath", "${relativeFile}" ], @@ -46,7 +46,7 @@ "args": [ "--runInBand", "--collectCoverage=false", - "--testTimeout 100000000" + "--testTimeout=100000000" ], "env": { "NODE_ENV": "test", @@ -73,7 +73,7 @@ "jest", "--runInBand", "--watchAll=false", - "--testTimeout 100000000" + "--testTimeout=100000000" ] } ] From 45451daebe18490b79add2a6119f79fba98bc021 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Thu, 16 Sep 2021 08:34:22 +0200 Subject: [PATCH 4/5] Update lib/util/git/url.spec.ts --- lib/util/git/url.spec.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/util/git/url.spec.ts b/lib/util/git/url.spec.ts index 0995356d5d9059..eceb04c32c2cbe 100644 --- a/lib/util/git/url.spec.ts +++ b/lib/util/git/url.spec.ts @@ -39,13 +39,6 @@ describe('util/git/url', () => { ); }); - it('returns https url with token with included username', () => { - hostRules.find.mockReturnValueOnce({ token: 'token' }); - expect( - getRemoteUrlWithToken('https://oauth2:token@foo.bar/bar/foo') - ).toBe('https://oauth2:token@foo.bar/bar/foo'); - }); - it('returns https url with token for non-http protocols', () => { hostRules.find.mockReturnValueOnce({ token: 'token' }); expect(getRemoteUrlWithToken('ssh://foo.bar/')).toBe( From 90f84439941dac625c28342dba4b9d724e532a6e Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Thu, 16 Sep 2021 08:34:36 +0200 Subject: [PATCH 5/5] Update lib/util/git/url.ts --- lib/util/git/url.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/util/git/url.ts b/lib/util/git/url.ts index 0f9066ed16d1a2..881de8722b3c6f 100644 --- a/lib/util/git/url.ts +++ b/lib/util/git/url.ts @@ -5,11 +5,7 @@ import * as hostRules from '../host-rules'; export function getHttpUrl(url: string, token?: string): string { const parsedUrl = GitUrlParse(url); - if (parsedUrl.user.includes(token)) { - parsedUrl.token = parsedUrl.user; - } else { - parsedUrl.token = token; - } + parsedUrl.token = token; const protocol = /^https?$/.exec(parsedUrl.protocol) ? parsedUrl.protocol