mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 04:15:30 +00:00
fix private repo clone issue for gitlab
This commit is contained in:
parent
395afcf563
commit
d920d0d167
1 changed files with 13 additions and 5 deletions
|
|
@ -217,14 +217,22 @@ export class RepoManager implements IRepoManager {
|
|||
this.logger.info(`Cloning ${repo.id}...`);
|
||||
|
||||
const token = await this.getTokenForRepo(repo, this.db);
|
||||
let cloneUrl = repo.cloneUrl;
|
||||
const cloneUrl = new URL(repo.cloneUrl);
|
||||
if (token) {
|
||||
const url = new URL(cloneUrl);
|
||||
url.username = token;
|
||||
cloneUrl = url.toString();
|
||||
switch (repo.external_codeHostType) {
|
||||
case 'gitlab':
|
||||
cloneUrl.username = 'oauth2';
|
||||
cloneUrl.password = token;
|
||||
break;
|
||||
case 'gitea':
|
||||
case 'github':
|
||||
default:
|
||||
cloneUrl.username = token;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const { durationMs } = await measure(() => cloneRepository(cloneUrl, repoPath, metadata.gitConfig, ({ method, stage, progress }) => {
|
||||
const { durationMs } = await measure(() => cloneRepository(cloneUrl.toString(), repoPath, metadata.gitConfig, ({ method, stage, progress }) => {
|
||||
//this.logger.info(`git.${method} ${stage} stage ${progress}% complete for ${repo.id}`)
|
||||
}));
|
||||
cloneDuration_s = durationMs / 1000;
|
||||
|
|
|
|||
Loading…
Reference in a new issue