@@ -19,11 +19,12 @@ import * as cli from '../cli';
1919import { logger } from '../logging' ;
2020import { getActionBranch , getRemoteControllerRepo , setRemoteControllerRepo } from '../config' ;
2121import { ProgressCallback , UserCancellationException } from '../commandRunner' ;
22- import { OctokitResponse } from '@octokit/types/dist-types' ;
22+ import { OctokitResponse , RequestError } from '@octokit/types/dist-types' ;
2323import { RemoteQuery } from './remote-query' ;
2424import { RemoteQuerySubmissionResult } from './remote-query-submission-result' ;
2525import { QueryMetadata } from '../pure/interface-types' ;
2626import { getErrorMessage , REPO_REGEX } from '../pure/helpers-pure' ;
27+ import * as ghApiClient from './gh-api/gh-api-client' ;
2728import { getRepositorySelection , isValidSelection , RepositorySelection } from './repository-selection' ;
2829
2930export interface QlPack {
@@ -212,29 +213,31 @@ export async function runRemoteQuery(
212213
213214 // Get the controller repo from the config, if it exists.
214215 // If it doesn't exist, prompt the user to enter it, and save that value to the config.
215- let controllerRepo : string | undefined ;
216- controllerRepo = getRemoteControllerRepo ( ) ;
217- if ( ! controllerRepo || ! REPO_REGEX . test ( controllerRepo ) ) {
218- void logger . log ( controllerRepo ? 'Invalid controller repository name.' : 'No controller repository defined.' ) ;
219- controllerRepo = await window . showInputBox ( {
216+ let controllerRepoNwo : string | undefined ;
217+ controllerRepoNwo = getRemoteControllerRepo ( ) ;
218+ if ( ! controllerRepoNwo || ! REPO_REGEX . test ( controllerRepoNwo ) ) {
219+ void logger . log ( controllerRepoNwo ? 'Invalid controller repository name.' : 'No controller repository defined.' ) ;
220+ controllerRepoNwo = await window . showInputBox ( {
220221 title : 'Controller repository in which to run the GitHub Actions workflow for this variant analysis' ,
221222 placeHolder : '<owner>/<repo>' ,
222223 prompt : 'Enter the name of a GitHub repository in the format <owner>/<repo>' ,
223224 ignoreFocusOut : true ,
224225 } ) ;
225- if ( ! controllerRepo ) {
226+ if ( ! controllerRepoNwo ) {
226227 void showAndLogErrorMessage ( 'No controller repository entered.' ) ;
227228 return ;
228- } else if ( ! REPO_REGEX . test ( controllerRepo ) ) { // Check if user entered invalid input
229+ } else if ( ! REPO_REGEX . test ( controllerRepoNwo ) ) { // Check if user entered invalid input
229230 void showAndLogErrorMessage ( 'Invalid repository format. Must be a valid GitHub repository in the format <owner>/<repo>.' ) ;
230231 return ;
231232 }
232- void logger . log ( `Setting the controller repository as: ${ controllerRepo } ` ) ;
233- await setRemoteControllerRepo ( controllerRepo ) ;
233+ void logger . log ( `Setting the controller repository as: ${ controllerRepoNwo } ` ) ;
234+ await setRemoteControllerRepo ( controllerRepoNwo ) ;
234235 }
235236
236- void logger . log ( `Using controller repository: ${ controllerRepo } ` ) ;
237- const [ owner , repo ] = controllerRepo . split ( '/' ) ;
237+ void logger . log ( `Using controller repository: ${ controllerRepoNwo } ` ) ;
238+ const [ owner , repo ] = controllerRepoNwo . split ( '/' ) ;
239+ const controllerRepoId = await getControllerRepoId ( credentials , owner , repo ) ;
240+ void logger . log ( `Controller repository ID: ${ controllerRepoId } ` ) ;
238241
239242 progress ( {
240243 maxStep : 4 ,
@@ -451,3 +454,15 @@ async function buildRemoteQueryEntity(
451454 repositoryCount,
452455 } ;
453456}
457+
458+ async function getControllerRepoId ( credentials : Credentials , owner : string , repo : string ) : Promise < number > {
459+ try {
460+ return await ghApiClient . getRepositoryIdFromNwo ( credentials , owner , repo ) ;
461+ } catch ( e : any ) {
462+ if ( ( e as RequestError ) . status === 404 ) {
463+ throw new Error ( `Controller repository "${ owner } /${ repo } " not found` ) ;
464+ } else {
465+ throw new Error ( `Error getting controller repository "${ owner } /${ repo } ": ${ e . message } ` ) ;
466+ }
467+ }
468+ }
0 commit comments