Permalink
Browse files

feat(): cloning of github private repository

  • Loading branch information...
Izak88 committed Sep 1, 2017
1 parent ba73615 commit 704fe27ac06a468a93b7cd5459b15b444ffc23b7
Showing with 16 additions and 14 deletions.
  1. +16 −14 src/api/config.ts
@@ -101,20 +101,22 @@ export function getRepositoryDetails(repository, sha = null, pr = null): Promise
.then(tempDir => {
let cloneUrl = repository.clone_url;
cloneDir = tempDir;
if (repository.private && repository.gitlab_id && repository.access_token) {
cloneUrl =
cloneUrl.replace('https://', `https://gitlab-ci-token:${repository.access_token}@`);
} else if (repository.private && repository.gogs_id && repository.access_token) {
cloneUrl = cloneUrl.replace('https://', `https://${repository.access_token}@`);
} else if (repository.bitbucket_id && repository.private && repository.access_token) {
return getBitBucketAccessToken(repository.access_token)
.then(response => {
let access_token = JSON.parse(response).access_token;
let cloneUrl =
repository.clone_url.replace('https://', `https://x-token-auth:${access_token}@`);

return spawn('git', ['clone', cloneUrl, '--depth', '1', cloneDir]);
}).catch(err => Promise.reject(err));
if (repository.private && repository.access_token) {
if (repository.github_id || repository.gogs_id) {
cloneUrl = cloneUrl.replace('https://', `https://${repository.access_token}@`);
} else if (repository.gitlab_id) {
cloneUrl =
cloneUrl.replace('https://', `https://gitlab-ci-token:${repository.access_token}@`);
} else if (repository.bitbucket_id && repository.private && repository.access_token) {
return getBitBucketAccessToken(repository.access_token)
.then(response => {
let access_token = JSON.parse(response).access_token;
let cloneUrl =
repository.clone_url.replace('https://', `https://x-token-auth:${access_token}@`);

return spawn('git', ['clone', cloneUrl, '--depth', '1', cloneDir]);
}).catch(err => Promise.reject(err));
}
}

return spawn('git', ['clone', cloneUrl, '--depth', '1', cloneDir]);

0 comments on commit 704fe27

Please sign in to comment.