Check controller repo before we set it (#2116)
This commit is contained in:
@@ -365,7 +365,10 @@ export async function getControllerRepo(
|
||||
credentials: Credentials,
|
||||
): Promise<Repository> {
|
||||
// Get the controller repo from the config, if it exists.
|
||||
// If it doesn't exist, prompt the user to enter it, and save that value to the config.
|
||||
// If it doesn't exist, prompt the user to enter it, check
|
||||
// whether the repo exists, and save the nwo to the config.
|
||||
|
||||
let shouldSetControllerRepo = false;
|
||||
let controllerRepoNwo: string | undefined;
|
||||
controllerRepoNwo = getRemoteControllerRepo();
|
||||
if (!controllerRepoNwo || !REPO_REGEX.test(controllerRepoNwo)) {
|
||||
@@ -390,15 +393,31 @@ export async function getControllerRepo(
|
||||
"Invalid repository format. Must be a valid GitHub repository in the format <owner>/<repo>.",
|
||||
);
|
||||
}
|
||||
|
||||
shouldSetControllerRepo = true;
|
||||
}
|
||||
|
||||
void extLogger.log(`Using controller repository: ${controllerRepoNwo}`);
|
||||
const controllerRepo = await getControllerRepoFromApi(
|
||||
credentials,
|
||||
controllerRepoNwo,
|
||||
);
|
||||
|
||||
if (shouldSetControllerRepo) {
|
||||
void extLogger.log(
|
||||
`Setting the controller repository as: ${controllerRepoNwo}`,
|
||||
);
|
||||
await setRemoteControllerRepo(controllerRepoNwo);
|
||||
}
|
||||
|
||||
void extLogger.log(`Using controller repository: ${controllerRepoNwo}`);
|
||||
const [owner, repo] = controllerRepoNwo.split("/");
|
||||
return controllerRepo;
|
||||
}
|
||||
|
||||
async function getControllerRepoFromApi(
|
||||
credentials: Credentials,
|
||||
nwo: string,
|
||||
): Promise<Repository> {
|
||||
const [owner, repo] = nwo.split("/");
|
||||
try {
|
||||
const controllerRepo = await getRepositoryFromNwo(credentials, owner, repo);
|
||||
void extLogger.log(`Controller repository ID: ${controllerRepo.id}`);
|
||||
@@ -419,6 +438,7 @@ export async function getControllerRepo(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function removeWorkspaceRefs(qlpack: QlPack) {
|
||||
for (const [key, value] of Object.entries(qlpack.dependencies || {})) {
|
||||
if (value === "${workspace}") {
|
||||
|
||||
Reference in New Issue
Block a user