revert: "fix: do not convert ssh repositoryUrl to https"
				
					
				
			This reverts commit b89523105cf04298f1f44858a02cc76c6c5dd0a5.
This commit is contained in:
		
							parent
							
								
									b89523105c
								
							
						
					
					
						commit
						93377eb636
					
				| @ -47,18 +47,10 @@ module.exports = async ({cwd, env, options: {repositoryUrl, branch}}) => { | |||||||
|     const envVar = Object.keys(GIT_TOKENS).find(envVar => !isUndefined(env[envVar])); |     const envVar = Object.keys(GIT_TOKENS).find(envVar => !isUndefined(env[envVar])); | ||||||
|     const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`; |     const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`; | ||||||
|     const {protocols, ...parsed} = gitUrlParse(repositoryUrl); |     const {protocols, ...parsed} = gitUrlParse(repositoryUrl); | ||||||
|     const protocol = protocols.includes('https') |     const protocol = protocols.includes('https') ? 'https' : protocols.includes('http') ? 'http' : 'https'; | ||||||
|       ? 'https' |  | ||||||
|       : protocols.includes('http') |  | ||||||
|         ? 'http' |  | ||||||
|         : protocols.includes('ssh') |  | ||||||
|           ? 'ssh' |  | ||||||
|           : 'https'; |  | ||||||
| 
 | 
 | ||||||
|     // If credentials are set via anvironment variables, convert the URL to http/https and add basic auth, otherwise return `repositoryUrl` as is
 |     // 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) |     return gitCredentials ? {...parsed, protocols: [protocol], user: gitCredentials}.toString(protocol) : repositoryUrl; | ||||||
|       ? {...parsed, protocols: [protocol], user: gitCredentials}.toString(protocol) |  | ||||||
|       : repositoryUrl; |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return repositoryUrl; |   return repositoryUrl; | ||||||
|  | |||||||
| @ -265,16 +265,3 @@ test('Do not add git credential to repositoryUrl if push is allowed', async t => | |||||||
|     repositoryUrl |     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' |  | ||||||
|   ); |  | ||||||
| }); |  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user