Compare commits

...
2 Commits
3 changed files with 3 additions and 24 deletions
+2 -10
View File
@@ -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;
+1 -1
View File
@@ -31,7 +31,7 @@
"execa": "^0.10.0",
"figures": "^2.0.0",
"find-versions": "^2.0.0",
"get-stream": "^3.0.0",
"get-stream": "^4.0.0",
"git-log-parser": "^1.2.0",
"git-url-parse": "^10.0.1",
"hook-std": "^1.1.0",
-13
View File
@@ -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'
);
});