mirror of
https://github.com/github/codeql-action.git
synced 2026-04-29 18:30:14 +00:00
only insert external repos token if supplied
This commit is contained in:
+18
-5
@@ -29,13 +29,10 @@ export async function checkoutExternalRepository(
|
||||
}
|
||||
|
||||
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"), [
|
||||
@@ -48,3 +45,19 @@ export async function checkoutExternalRepository(
|
||||
|
||||
return checkoutLocation;
|
||||
}
|
||||
|
||||
export function buildCheckoutURL(
|
||||
repository: string,
|
||||
apiDetails: GitHubApiExternalRepoDetails
|
||||
): string {
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user