@@ -187,72 +187,108 @@ async function getPackedBundlePath(queryPackDir: string) {
187187 } ) ;
188188}
189189
190- export async function runRemoteQuery (
190+ export async function prepareRemoteQueryRun (
191191 cliServer : cli . CodeQLCliServer ,
192192 credentials : Credentials ,
193193 uri : Uri | undefined ,
194- dryRun : boolean ,
194+ queryPackDir : string ,
195195 progress : ProgressCallback ,
196196 token : CancellationToken ,
197- variantAnalysisManager : VariantAnalysisManager
198- ) : Promise < void | RemoteQuerySubmissionResult > {
197+ ) {
199198 if ( ! ( await cliServer . cliConstraints . supportsRemoteQueries ( ) ) ) {
200199 throw new Error ( `Variant analysis is not supported by this version of CodeQL. Please upgrade to v${ cli . CliVersionConstraint . CLI_VERSION_REMOTE_QUERIES
201200 } or later.`) ;
202201 }
203202
204- const { remoteQueryDir, queryPackDir } = await createRemoteQueriesTempDirectory ( ) ;
205- try {
206- if ( ! uri ?. fsPath . endsWith ( '.ql' ) ) {
207- throw new UserCancellationException ( 'Not a CodeQL query file.' ) ;
208- }
203+ if ( ! uri ?. fsPath . endsWith ( '.ql' ) ) {
204+ throw new UserCancellationException ( 'Not a CodeQL query file.' ) ;
205+ }
209206
210- const queryFile = uri . fsPath ;
207+ const queryFile = uri . fsPath ;
211208
212- progress ( {
213- maxStep : 4 ,
214- step : 1 ,
215- message : 'Determining query target language'
216- } ) ;
209+ progress ( {
210+ maxStep : 4 ,
211+ step : 1 ,
212+ message : 'Determining query target language'
213+ } ) ;
217214
218- const repoSelection = await getRepositorySelection ( ) ;
219- if ( ! isValidSelection ( repoSelection ) ) {
220- throw new UserCancellationException ( 'No repositories to query.' ) ;
221- }
215+ const repoSelection = await getRepositorySelection ( ) ;
216+ if ( ! isValidSelection ( repoSelection ) ) {
217+ throw new UserCancellationException ( 'No repositories to query.' ) ;
218+ }
222219
223- progress ( {
224- maxStep : 4 ,
225- step : 2 ,
226- message : 'Determining controller repo'
227- } ) ;
220+ progress ( {
221+ maxStep : 4 ,
222+ step : 2 ,
223+ message : 'Determining controller repo'
224+ } ) ;
228225
229- const controllerRepo = await getControllerRepo ( credentials ) ;
226+ const controllerRepo = await getControllerRepo ( credentials ) ;
230227
231- progress ( {
232- maxStep : 4 ,
233- step : 3 ,
234- message : 'Bundling the query pack'
235- } ) ;
228+ progress ( {
229+ maxStep : 4 ,
230+ step : 3 ,
231+ message : 'Bundling the query pack'
232+ } ) ;
236233
237- if ( token . isCancellationRequested ) {
238- throw new UserCancellationException ( 'Cancelled' ) ;
239- }
234+ if ( token . isCancellationRequested ) {
235+ throw new UserCancellationException ( 'Cancelled' ) ;
236+ }
240237
241- const { base64Pack, language } = await generateQueryPack ( cliServer , queryFile , queryPackDir ) ;
238+ const { base64Pack, language } = await generateQueryPack ( cliServer , queryFile , queryPackDir ) ;
242239
243- if ( token . isCancellationRequested ) {
244- throw new UserCancellationException ( 'Cancelled' ) ;
245- }
240+ if ( token . isCancellationRequested ) {
241+ throw new UserCancellationException ( 'Cancelled' ) ;
242+ }
246243
247- progress ( {
248- maxStep : 4 ,
249- step : 4 ,
250- message : 'Sending request'
251- } ) ;
244+ progress ( {
245+ maxStep : 4 ,
246+ step : 4 ,
247+ message : 'Sending request'
248+ } ) ;
249+
250+ const actionBranch = getActionBranch ( ) ;
251+ const queryStartTime = Date . now ( ) ;
252+ const queryMetadata = await tryGetQueryMetadata ( cliServer , queryFile ) ;
252253
253- const actionBranch = getActionBranch ( ) ;
254- const queryStartTime = Date . now ( ) ;
255- const queryMetadata = await tryGetQueryMetadata ( cliServer , queryFile ) ;
254+ return {
255+ actionBranch,
256+ base64Pack,
257+ repoSelection,
258+ queryFile,
259+ queryMetadata,
260+ controllerRepo,
261+ queryStartTime,
262+ language,
263+ } ;
264+ }
265+
266+ export async function runRemoteQuery (
267+ cliServer : cli . CodeQLCliServer ,
268+ credentials : Credentials ,
269+ uri : Uri | undefined ,
270+ dryRun : boolean ,
271+ progress : ProgressCallback ,
272+ token : CancellationToken ,
273+ variantAnalysisManager : VariantAnalysisManager
274+ ) : Promise < void | RemoteQuerySubmissionResult > {
275+ if ( ! ( await cliServer . cliConstraints . supportsRemoteQueries ( ) ) ) {
276+ throw new Error ( `Variant analysis is not supported by this version of CodeQL. Please upgrade to v${ cli . CliVersionConstraint . CLI_VERSION_REMOTE_QUERIES
277+ } or later.`) ;
278+ }
279+
280+ const { remoteQueryDir, queryPackDir } = await createRemoteQueriesTempDirectory ( ) ;
281+ try {
282+ const {
283+ actionBranch,
284+ base64Pack,
285+ repoSelection,
286+ queryFile,
287+ queryMetadata,
288+ controllerRepo,
289+ queryStartTime,
290+ language,
291+ } = await prepareRemoteQueryRun ( cliServer , credentials , uri , queryPackDir , progress , token ) ;
256292
257293 if ( isVariantAnalysisLiveResultsEnabled ( ) ) {
258294 const queryName = getQueryName ( queryMetadata , queryFile ) ;
0 commit comments