diff --git a/lib/get-git-auth-url.js b/lib/get-git-auth-url.js index a51ee9ed..863879ba 100644 --- a/lib/get-git-auth-url.js +++ b/lib/get-git-auth-url.js @@ -47,18 +47,10 @@ module.exports = async ({cwd, env, options: {repositoryUrl, branch}}) => { const envVar = Object.keys(GIT_TOKENS).find(envVar => !isUndefined(env[envVar])); const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`; const {protocols, ...parsed} = gitUrlParse(repositoryUrl); - const protocol = protocols.includes('https') - ? 'https' - : protocols.includes('http') - ? 'http' - : protocols.includes('ssh') - ? 'ssh' - : 'https'; + const protocol = protocols.includes('https') ? 'https' : protocols.includes('http') ? 'http' : 'https'; // If credentials are set via anvironment variables, convert the URL to http/https and add basic auth, otherwise return `repositoryUrl` as is - return gitCredentials && ['https', 'http'].includes(protocol) - ? {...parsed, protocols: [protocol], user: gitCredentials}.toString(protocol) - : repositoryUrl; + return gitCredentials ? {...parsed, protocols: [protocol], user: gitCredentials}.toString(protocol) : repositoryUrl; } return repositoryUrl; diff --git a/test/get-git-auth-url.test.js b/test/get-git-auth-url.test.js index f71265e9..e0c4828a 100644 --- a/test/get-git-auth-url.test.js +++ b/test/get-git-auth-url.test.js @@ -265,16 +265,3 @@ test('Do not add git credential to repositoryUrl if push is allowed', async t => repositoryUrl ); }); - -test('Do not add git credentials if repositoryUrl is a "ssh" URL', async t => { - const {cwd} = await gitRepo(); - - t.is( - await getAuthUrl({ - cwd, - env: {...env, GIT_CREDENTIALS: 'user:pass'}, - options: {branch: 'master', repositoryUrl: 'ssh://git@host.null/owner/repo.git'}, - }), - 'ssh://git@host.null/owner/repo.git' - ); -});