1- import { CancellationToken , QuickPickItem , Uri , window } from 'vscode' ;
1+ import { CancellationToken , Uri , window } from 'vscode' ;
22import * as path from 'path' ;
33import * as yaml from 'js-yaml' ;
44import * as fs from 'fs-extra' ;
@@ -15,13 +15,14 @@ import {
1515import { Credentials } from '../authentication' ;
1616import * as cli from '../cli' ;
1717import { logger } from '../logging' ;
18- import { getActionBranch , getRemoteControllerRepo , getRemoteRepositoryLists , setRemoteControllerRepo } from '../config' ;
18+ import { getActionBranch , getRemoteControllerRepo , setRemoteControllerRepo } from '../config' ;
1919import { ProgressCallback , UserCancellationException } from '../commandRunner' ;
2020import { OctokitResponse } from '@octokit/types/dist-types' ;
2121import { RemoteQuery } from './remote-query' ;
2222import { RemoteQuerySubmissionResult } from './remote-query-submission-result' ;
2323import { QueryMetadata } from '../pure/interface-types' ;
2424import { getErrorMessage , REPO_REGEX } from '../pure/helpers-pure' ;
25+ import { getRepositories } from './repository-selection' ;
2526
2627export interface QlPack {
2728 name : string ;
@@ -30,9 +31,6 @@ export interface QlPack {
3031 defaultSuite ?: Record < string , unknown > [ ] ;
3132 defaultSuiteFile ?: string ;
3233}
33- interface RepoListQuickPickItem extends QuickPickItem {
34- repoList : string [ ] ;
35- }
3634
3735interface QueriesResponse {
3836 workflow_run_id : number
@@ -43,51 +41,6 @@ interface QueriesResponse {
4341 */
4442const QUERY_PACK_NAME = 'codeql-remote/query' ;
4543
46- /**
47- * Gets the repositories to run the query against.
48- */
49- export async function getRepositories ( ) : Promise < string [ ] | undefined > {
50- const repoLists = getRemoteRepositoryLists ( ) ;
51- if ( repoLists && Object . keys ( repoLists ) . length ) {
52- const quickPickItems = Object . entries ( repoLists ) . map < RepoListQuickPickItem > ( ( [ key , value ] ) => (
53- {
54- label : key , // the name of the repository list
55- repoList : value , // the actual array of repositories
56- }
57- ) ) ;
58- const quickpick = await window . showQuickPick < RepoListQuickPickItem > (
59- quickPickItems ,
60- {
61- placeHolder : 'Select a repository list. You can define repository lists in the `codeQL.variantAnalysis.repositoryLists` setting.' ,
62- ignoreFocusOut : true ,
63- } ) ;
64- if ( quickpick ?. repoList . length ) {
65- void logger . log ( `Selected repositories: ${ quickpick . repoList . join ( ', ' ) } ` ) ;
66- return quickpick . repoList ;
67- } else {
68- void showAndLogErrorMessage ( 'No repositories selected.' ) ;
69- return ;
70- }
71- } else {
72- void logger . log ( 'No repository lists defined. Displaying text input box.' ) ;
73- const remoteRepo = await window . showInputBox ( {
74- title : 'Enter a GitHub repository in the format <owner>/<repo> (e.g. github/codeql)' ,
75- placeHolder : '<owner>/<repo>' ,
76- prompt : 'Tip: you can save frequently used repositories in the `codeQL.variantAnalysis.repositoryLists` setting' ,
77- ignoreFocusOut : true ,
78- } ) ;
79- if ( ! remoteRepo ) {
80- void showAndLogErrorMessage ( 'No repositories entered.' ) ;
81- return ;
82- } else if ( ! REPO_REGEX . test ( remoteRepo ) ) { // Check if user entered invalid input
83- void showAndLogErrorMessage ( 'Invalid repository format. Must be in the format <owner>/<repo> (e.g. github/codeql)' ) ;
84- return ;
85- }
86- void logger . log ( `Entered repository: ${ remoteRepo } ` ) ;
87- return [ remoteRepo ] ;
88- }
89- }
90-
9144/**
9245 * Two possibilities:
9346 * 1. There is no qlpack.yml in this directory. Assume this is a lone query and generate a synthetic qlpack for it.
0 commit comments