Skip to content
Permalink
Browse files

Fall through to no creds for cloneUrl

[changelog:changed]
  • Loading branch information...
cdupuis committed Jan 24, 2019
1 parent fcfb683 commit b31ba59eca489d9bfea5528046ed52800f6a7bc5
Showing with 6 additions and 8 deletions.
  1. +5 −8 lib/operations/common/AbstractRemoteRepoRef.ts
  2. +1 −0 lib/project/git/GitCommandGitProject.ts
@@ -83,21 +83,18 @@ export abstract class AbstractRemoteRepoRef implements RemoteRepoRef {
}

public cloneUrl(creds: ProjectOperationCredentials) {
if (!creds) {
throw new Error("Credentials are undefined");
}
if (isBasicAuthCredentials(creds)) {
if (!!creds && isBasicAuthCredentials(creds)) {
return `${this.scheme}${encodeURIComponent(creds.username)}:${encodeURIComponent(creds.password)}@` +
`${this.remoteBase}/${this.pathComponent}.git`;
}
if (isGitlabPrivateTokenCredentials(creds)) {
if (!!creds && isGitlabPrivateTokenCredentials(creds)) {
return `${this.scheme}gitlab-ci-token:${creds.privateToken}@` +
`${this.remoteBase}/${this.pathComponent}.git`;
}
if (!isTokenCredentials(creds)) {
throw new Error("Only token or basic auth supported");
if (!!creds && isTokenCredentials(creds)) {
return `${this.scheme}${creds.token}:x-oauth-basic@${this.remoteBase}/${this.pathComponent}.git`;
}
return `${this.scheme}${creds.token}:x-oauth-basic@${this.remoteBase}/${this.pathComponent}.git`;
return `${this.scheme}${this.remoteBase}/${this.pathComponent}.git`;
}

get pathComponent(): string {
@@ -355,6 +355,7 @@ async function cloneInto(
// Or don't, but then call gitStatus() on the returned project to check whether the branch is still at the SHA you wanted.
const checkoutRef = opts.detachHead ? sha : id.branch || sha;

// TODO CD user:password should be replaced too
const cleanUrl = url.replace(/\/\/.*:x-oauth-basic/, "//TOKEN:x-oauth-basic");
logger.debug(`Cloning repo '${cleanUrl}' in '${repoDir}'`);
const retryOptions = {

0 comments on commit b31ba59

Please sign in to comment.
You can’t perform that action at this time.