in wiki-interface/lib/git/utils.js [24:59]
async function cloneGitRepo(repositoryUrl, accessToken, transID) {
let exists = promisify(fs.exists);
let formattedRepoUrl = "";
let targetPath = configFile.getWorkDir() + "/" + transID
try {
// Check if the repository already exists locally
let repoExists = await exists(targetPath);
// Adding access token to our URL
if(accessToken != "") {
if (repositoryUrl.includes("https://")) {
formattedRepoUrl = repositoryUrl.replace('https://', `https://wiki-interface:${accessToken}@`);
} else {
formattedRepoUrl = repositoryUrl.replace('http://', `http://wiki-interface:${accessToken}@`);
}
} else {
formattedRepoUrl = repositoryUrl;
}
const git = simpleGit();
if (repoExists) {
// Repository exists, pull latest changes
await git.cwd(targetPath).pull(formattedRepoUrl, 'master', { '--depth': 1000 });
} else {
// Repository doesn't exist, clone it
await git.clone(formattedRepoUrl, targetPath, ['--depth=1000']);
}
} catch (error) {
console.error('Synchronization failed:', error);
}
}