mirror of
https://github.com/github/codeql-action.git
synced 2026-10-31 09:59:43 +00:00
Refactor parseNewRemoteFileAddress out of parseRemoteFileAddress
This commit is contained in:
41
lib/entry-points.js
generated
41
lib/entry-points.js
generated
@@ -148296,6 +148296,25 @@ function parseOldRemoteFileAddress(input) {
|
||||
ref: pieces.groups.ref.trim()
|
||||
});
|
||||
}
|
||||
function parseNewRemoteFileAddress(env, configFile) {
|
||||
const format = new RegExp(
|
||||
"^((?<owner>[^:@/]+)/)?(?<repo>[^:@/]+)(@(?<ref>[^:]+))?(:(?<path>.+))?$"
|
||||
);
|
||||
const pieces = format.exec(configFile.trim());
|
||||
const repo = pieces?.groups?.repo?.trim();
|
||||
if (!pieces?.groups || !repo || repo.length === 0) {
|
||||
return new Failure(void 0);
|
||||
}
|
||||
const owner = pieces.groups.owner?.trim();
|
||||
const path29 = pieces.groups.path?.trim();
|
||||
const ref = pieces.groups.ref?.trim();
|
||||
return new Success({
|
||||
owner: owner || getDefaultOwner(env),
|
||||
repo,
|
||||
path: path29 || DEFAULT_CONFIG_FILE_NAME,
|
||||
ref: ref || DEFAULT_CONFIG_FILE_REF
|
||||
});
|
||||
}
|
||||
async function parseRemoteFileAddress(actionState, configFile) {
|
||||
const oldFormatAddressResult = parseOldRemoteFileAddress(configFile);
|
||||
if (oldFormatAddressResult.isSuccess()) {
|
||||
@@ -148309,30 +148328,22 @@ async function parseRemoteFileAddress(actionState, configFile) {
|
||||
getConfigFileRepoOldFormatInvalidMessage(configFile)
|
||||
);
|
||||
}
|
||||
const format = new RegExp(
|
||||
"^((?<owner>[^:@/]+)/)?(?<repo>[^:@/]+)(@(?<ref>[^:]+))?(:(?<path>.+))?$"
|
||||
const newFormatAddressResult = parseNewRemoteFileAddress(
|
||||
actionState.env,
|
||||
configFile
|
||||
);
|
||||
const pieces = format.exec(configFile.trim());
|
||||
const repo = pieces?.groups?.repo?.trim();
|
||||
if (!pieces?.groups || !repo || repo.length === 0) {
|
||||
if (newFormatAddressResult.isFailure()) {
|
||||
throw new ConfigurationError(
|
||||
getConfigFileRepoFormatInvalidMessage(configFile)
|
||||
);
|
||||
}
|
||||
const owner = pieces.groups.owner?.trim();
|
||||
const path29 = pieces.groups.path?.trim();
|
||||
const ref = pieces.groups.ref?.trim();
|
||||
if (path29?.startsWith("/")) {
|
||||
const address = newFormatAddressResult.value;
|
||||
if (address.path.startsWith("/")) {
|
||||
throw new ConfigurationError(
|
||||
`The path component of '${configFile}' cannot be an absolute path.`
|
||||
);
|
||||
}
|
||||
return {
|
||||
owner: owner || getDefaultOwner(actionState.env),
|
||||
repo,
|
||||
path: path29 || DEFAULT_CONFIG_FILE_NAME,
|
||||
ref: ref || DEFAULT_CONFIG_FILE_REF
|
||||
};
|
||||
return address;
|
||||
}
|
||||
|
||||
// src/config/file.ts
|
||||
|
||||
Reference in New Issue
Block a user