Skip to content

Commit

Permalink
revert: "fix: do not convert ssh repositoryUrl to https"
Browse files Browse the repository at this point in the history
This reverts commit b895231.
  • Loading branch information
pvdlg committed Aug 10, 2018
1 parent b895231 commit 93377eb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
12 changes: 2 additions & 10 deletions lib/get-git-auth-url.js
Expand Up @@ -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;
Expand Down
13 changes: 0 additions & 13 deletions test/get-git-auth-url.test.js
Expand Up @@ -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'
);
});

0 comments on commit 93377eb

Please sign in to comment.