@@ -8,11 +8,12 @@ import { Credentials } from '../authentication';
88import * as cli from '../cli' ;
99import { logger } from '../logging' ;
1010import { getRemoteControllerRepo , getRemoteRepositoryLists , setRemoteControllerRepo } from '../config' ;
11- import { tmpDir } from '../run-queries' ;
11+ import { getQueryMetadata , tmpDir } from '../run-queries' ;
1212import { ProgressCallback , UserCancellationException } from '../commandRunner' ;
1313import { OctokitResponse } from '@octokit/types/dist-types' ;
1414import { RemoteQuery } from './remote-query' ;
1515import { RemoteQuerySubmissionResult } from './remote-query-submission-result' ;
16+ import { QueryMetadata } from '../pure/interface-types' ;
1617
1718interface Config {
1819 repositories : string [ ] ;
@@ -323,6 +324,7 @@ export async function runRemoteQuery(
323324
324325 const workflowRunId = await runRemoteQueriesApiRequest ( credentials , ref , language , repositories , owner , repo , base64Pack , dryRun ) ;
325326 const queryStartTime = new Date ( ) ;
327+ const queryMetadata = await getQueryMetadata ( cliServer , queryFile ) ;
326328
327329 if ( dryRun ) {
328330 return { queryDirPath : remoteQueryDir . path } ;
@@ -331,7 +333,7 @@ export async function runRemoteQuery(
331333 return ;
332334 }
333335
334- const remoteQuery = await buildRemoteQueryEntity ( repositories , queryFile , owner , repo , queryStartTime , workflowRunId ) ;
336+ const remoteQuery = await buildRemoteQueryEntity ( repositories , queryFile , queryMetadata , owner , repo , queryStartTime , workflowRunId ) ;
335337
336338 // don't return the path because it has been deleted
337339 return { query : remoteQuery } ;
@@ -454,13 +456,14 @@ async function ensureNameAndSuite(queryPackDir: string, packRelativePath: string
454456async function buildRemoteQueryEntity (
455457 repositories : string [ ] ,
456458 queryFilePath : string ,
459+ queryMetadata : QueryMetadata | undefined ,
457460 controllerRepoOwner : string ,
458461 controllerRepoName : string ,
459462 queryStartTime : Date ,
460463 workflowRunId : number
461464) : Promise < RemoteQuery > {
462- // For now, just use the file name as the query name.
463- const queryName = path . basename ( queryFilePath ) ;
465+ // The query name is either the name as specified in the query metadata, or the file name.
466+ const queryName = queryMetadata ?. name ?? path . basename ( queryFilePath ) ;
464467
465468 const queryRepos = repositories . map ( r => {
466469 const [ owner , repo ] = r . split ( '/' ) ;
0 commit comments