Skip to content

Commit a75249f

Browse files
authored
Merge pull request #1132 from github/rneatherway/remove-repositories
Remove .repositories configuration approach
2 parents 053a4b0 + d49e6e1 commit a75249f

1 file changed

Lines changed: 13 additions & 44 deletions

File tree

extensions/ql-vscode/src/remote-queries/run-remote-query.ts

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ import { RemoteQuery } from './remote-query';
2323
import { RemoteQuerySubmissionResult } from './remote-query-submission-result';
2424
import { QueryMetadata } from '../pure/interface-types';
2525

26-
interface Config {
27-
repositories: string[];
28-
ref?: string;
29-
language?: string;
30-
}
31-
3226
export interface QlPack {
3327
name: string;
3428
version: string;
@@ -108,7 +102,7 @@ export async function getRepositories(): Promise<string[] | undefined> {
108102
*
109103
* @returns the entire qlpack as a base64 string.
110104
*/
111-
async function generateQueryPack(cliServer: cli.CodeQLCliServer, queryFile: string, queryPackDir: string, fallbackLanguage?: string): Promise<{
105+
async function generateQueryPack(cliServer: cli.CodeQLCliServer, queryFile: string, queryPackDir: string): Promise<{
112106
base64Pack: string,
113107
language: string
114108
}> {
@@ -150,7 +144,7 @@ async function generateQueryPack(cliServer: cli.CodeQLCliServer, queryFile: stri
150144

151145
} else {
152146
// open popup to ask for language if not already hardcoded
153-
language = fallbackLanguage || await askForLanguage(cliServer);
147+
language = await askForLanguage(cliServer);
154148

155149
// copy only the query file to the query pack directory
156150
// and generate a synthetic query pack
@@ -238,47 +232,22 @@ export async function runRemoteQuery(
238232
throw new UserCancellationException('Not a CodeQL query file.');
239233
}
240234

241-
progress({
242-
maxStep: 5,
243-
step: 1,
244-
message: 'Determining project list'
245-
});
246-
247235
const queryFile = uri.fsPath;
248-
const repositoriesFile = queryFile.substring(0, queryFile.length - '.ql'.length) + '.repositories';
249-
let ref: string | undefined;
250-
// For the case of single file remote queries, use the language from the config in order to avoid the user having to select it.
251-
let fallbackLanguage: string | undefined;
252-
let repositories: string[] | undefined;
253236

254237
progress({
255-
maxStep: 5,
256-
step: 2,
238+
maxStep: 4,
239+
step: 1,
257240
message: 'Determining query target language'
258241
});
259242

260-
// If the user has an explicit `.repositories` file, use that.
261-
// Otherwise, prompt user to select repositories from the `codeQL.remoteQueries.repositoryLists` setting.
262-
if (await fs.pathExists(repositoriesFile)) {
263-
void logger.log(`Found '${repositoriesFile}'. Using information from that file to run ${queryFile}.`);
264-
265-
const config = yaml.safeLoad(await fs.readFile(repositoriesFile, 'utf8')) as Config;
266-
267-
ref = config.ref || 'main';
268-
fallbackLanguage = config.language;
269-
repositories = config.repositories;
270-
} else {
271-
ref = 'main';
272-
repositories = await getRepositories();
273-
}
274-
243+
const repositories = await getRepositories();
275244
if (!repositories || repositories.length === 0) {
276245
throw new UserCancellationException('No repositories to query.');
277246
}
278247

279248
progress({
280-
maxStep: 5,
281-
step: 3,
249+
maxStep: 4,
250+
step: 2,
282251
message: 'Determining controller repo'
283252
});
284253

@@ -309,28 +278,28 @@ export async function runRemoteQuery(
309278
const [owner, repo] = controllerRepo.split('/');
310279

311280
progress({
312-
maxStep: 5,
313-
step: 4,
281+
maxStep: 4,
282+
step: 3,
314283
message: 'Bundling the query pack'
315284
});
316285

317286
if (token.isCancellationRequested) {
318287
throw new UserCancellationException('Cancelled');
319288
}
320289

321-
const { base64Pack, language } = await generateQueryPack(cliServer, queryFile, queryPackDir, fallbackLanguage);
290+
const { base64Pack, language } = await generateQueryPack(cliServer, queryFile, queryPackDir);
322291

323292
if (token.isCancellationRequested) {
324293
throw new UserCancellationException('Cancelled');
325294
}
326295

327296
progress({
328-
maxStep: 5,
329-
step: 5,
297+
maxStep: 4,
298+
step: 4,
330299
message: 'Sending request'
331300
});
332301

333-
const workflowRunId = await runRemoteQueriesApiRequest(credentials, ref, language, repositories, owner, repo, base64Pack, dryRun);
302+
const workflowRunId = await runRemoteQueriesApiRequest(credentials, 'main', language, repositories, owner, repo, base64Pack, dryRun);
334303
const queryStartTime = new Date();
335304
const queryMetadata = await tryGetQueryMetadata(cliServer, queryFile);
336305

0 commit comments

Comments
 (0)