mirror of
https://github.com/github/codeql-action
synced 2026-05-25 15:00:36 +03:00
only insert external repos token if supplied
This commit is contained in:
Generated
+15
-5
@@ -22,13 +22,10 @@ async function checkoutExternalRepository(repository, ref, apiDetails, tempDir,
|
||||
throw new Error(`'${repository}@${ref}' is not a valid repository and reference.`);
|
||||
}
|
||||
if (!fs.existsSync(checkoutLocation)) {
|
||||
const repoCloneURL = new URL(apiDetails.url);
|
||||
repoCloneURL.username = "x-access-token";
|
||||
repoCloneURL.password = apiDetails.externalRepoAuth;
|
||||
repoCloneURL.pathname += `/${repository}`;
|
||||
const repoCloneURL = buildCheckoutURL(repository, apiDetails);
|
||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), [
|
||||
"clone",
|
||||
repoCloneURL.toString(),
|
||||
repoCloneURL,
|
||||
checkoutLocation,
|
||||
]).exec();
|
||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), [
|
||||
@@ -41,4 +38,17 @@ async function checkoutExternalRepository(repository, ref, apiDetails, tempDir,
|
||||
return checkoutLocation;
|
||||
}
|
||||
exports.checkoutExternalRepository = checkoutExternalRepository;
|
||||
function buildCheckoutURL(repository, apiDetails) {
|
||||
const repoCloneURL = new URL(apiDetails.url);
|
||||
if (apiDetails.externalRepoAuth !== undefined) {
|
||||
repoCloneURL.username = "x-access-token";
|
||||
repoCloneURL.password = apiDetails.externalRepoAuth;
|
||||
}
|
||||
if (!repoCloneURL.pathname.endsWith("/")) {
|
||||
repoCloneURL.pathname += "/";
|
||||
}
|
||||
repoCloneURL.pathname += `${repository}`;
|
||||
return repoCloneURL.toString();
|
||||
}
|
||||
exports.buildCheckoutURL = buildCheckoutURL;
|
||||
//# sourceMappingURL=external-queries.js.map
|
||||
Reference in New Issue
Block a user