mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 17:39:50 +00:00
Return RemoteFileAddress from parseRemoteFileAddress
This commit is contained in:
@@ -45,15 +45,15 @@ export async function getRemoteConfig(
|
||||
apiDetails: api.GitHubApiCombinedDetails,
|
||||
validateConfig: boolean,
|
||||
): Promise<UserConfig> {
|
||||
const groups = parseRemoteFileAddress(configFile);
|
||||
const address = parseRemoteFileAddress(configFile);
|
||||
|
||||
const response = await api
|
||||
.getApiClientWithExternalAuth(apiDetails)
|
||||
.rest.repos.getContent({
|
||||
owner: groups.owner,
|
||||
repo: groups.repo,
|
||||
path: groups.path,
|
||||
ref: groups.ref,
|
||||
owner: address.owner,
|
||||
repo: address.repo,
|
||||
path: address.path,
|
||||
ref: address.ref,
|
||||
});
|
||||
|
||||
let fileContents: string;
|
||||
|
||||
@@ -20,7 +20,7 @@ export interface RemoteFileAddress {
|
||||
* @returns The successful result of executing the regex.
|
||||
* @throws `ConfigurationError` if the format of `configFile` is not valid.
|
||||
*/
|
||||
export function parseRemoteFileAddress(configFile: string) {
|
||||
export function parseRemoteFileAddress(configFile: string): RemoteFileAddress {
|
||||
// retrieve the various parts of the config location, and ensure they're present
|
||||
const format = new RegExp(
|
||||
"(?<owner>[^/]+)/(?<repo>[^/]+)/(?<path>[^@]+)@(?<ref>.*)",
|
||||
@@ -34,5 +34,10 @@ export function parseRemoteFileAddress(configFile: string) {
|
||||
);
|
||||
}
|
||||
|
||||
return pieces.groups;
|
||||
return {
|
||||
owner: pieces.groups.owner,
|
||||
repo: pieces.groups.repo,
|
||||
path: pieces.groups.path,
|
||||
ref: pieces.groups.ref,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user