Return RemoteFileAddress from parseRemoteFileAddress

This commit is contained in:
Michael B. Gale
2026-06-23 16:48:34 +01:00
parent 9ef8be7176
commit 82e5ca6c55
3 changed files with 23 additions and 13 deletions

View File

@@ -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;

View File

@@ -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,
};
}