Skip to content

Commit 66c0714

Browse files
Point ReleasesApiConsumer at nightly repo if config value is set
1 parent 0f437f7 commit 66c0714

2 files changed

Lines changed: 42 additions & 8 deletions

File tree

extensions/ql-vscode/src/codeql-cli/distribution.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ const DEFAULT_DISTRIBUTION_OWNER_NAME = "github";
5050
*/
5151
const DEFAULT_DISTRIBUTION_REPOSITORY_NAME = "codeql-cli-binaries";
5252

53+
/**
54+
* Owner name of the nightly version of the extension-managed distribution on GitHub.
55+
*/
56+
const NIGHTLY_DISTRIBUTION_OWNER_NAME = "dsp-testing";
57+
58+
/**
59+
* Repository name of the nightly version of the extension-managed distribution on GitHub.
60+
*/
61+
const NIGHTLY_DISTRIBUTION_REPOSITORY_NAME = "codeql-cli-nightlies";
62+
5363
/**
5464
* Range of versions of the CLI that are compatible with the extension.
5565
*
@@ -476,19 +486,33 @@ class ExtensionSpecificDistributionManager {
476486
}
477487

478488
private createReleasesApiConsumer(): ReleasesApiConsumer {
479-
const ownerName = this.config.ownerName
480-
? this.config.ownerName
481-
: DEFAULT_DISTRIBUTION_OWNER_NAME;
482-
const repositoryName = this.config.repositoryName
483-
? this.config.repositoryName
484-
: DEFAULT_DISTRIBUTION_REPOSITORY_NAME;
485489
return new ReleasesApiConsumer(
486-
ownerName,
487-
repositoryName,
490+
this.distributionOwnerName(),
491+
this.distributionRepositoryName(),
488492
this.config.personalAccessToken,
489493
);
490494
}
491495

496+
private distributionOwnerName(): string {
497+
if (this.config.ownerName) {
498+
return this.config.ownerName;
499+
} else if (this.config.channel === "nightly") {
500+
return NIGHTLY_DISTRIBUTION_OWNER_NAME;
501+
} else {
502+
return DEFAULT_DISTRIBUTION_OWNER_NAME;
503+
}
504+
}
505+
506+
private distributionRepositoryName(): string {
507+
if (this.config.repositoryName) {
508+
return this.config.repositoryName;
509+
} else if (this.config.channel === "nightly") {
510+
return NIGHTLY_DISTRIBUTION_REPOSITORY_NAME;
511+
} else {
512+
return DEFAULT_DISTRIBUTION_REPOSITORY_NAME;
513+
}
514+
}
515+
492516
private async bumpDistributionFolderIndex(): Promise<void> {
493517
const index = this.extensionContext.globalState.get(
494518
ExtensionSpecificDistributionManager._currentDistributionFolderIndexStateKey,

extensions/ql-vscode/src/config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const PERSONAL_ACCESS_TOKEN_SETTING = new Setting(
9595
"personalAccessToken",
9696
DISTRIBUTION_SETTING,
9797
);
98+
const CLI_CHANNEL_SETTING = new Setting("channel", DISTRIBUTION_SETTING);
9899

99100
// Query History configuration
100101
const QUERY_HISTORY_SETTING = new Setting("queryHistory", ROOT_SETTING);
@@ -111,13 +112,16 @@ const DISTRIBUTION_CHANGE_SETTINGS = [
111112
PERSONAL_ACCESS_TOKEN_SETTING,
112113
];
113114

115+
export type CLIChannel = "released" | "nightly";
116+
114117
export interface DistributionConfig {
115118
readonly customCodeQlPath?: string;
116119
updateCustomCodeQlPath: (newPath: string | undefined) => Promise<void>;
117120
includePrerelease: boolean;
118121
personalAccessToken?: string;
119122
ownerName?: string;
120123
repositoryName?: string;
124+
channel: CLIChannel;
121125
onDidChangeConfiguration?: Event<void>;
122126

123127
/**
@@ -283,6 +287,12 @@ export class DistributionConfigListener
283287
);
284288
}
285289

290+
public get channel(): CLIChannel {
291+
return CLI_CHANNEL_SETTING.getValue() === "nightly"
292+
? "nightly"
293+
: "released";
294+
}
295+
286296
public forceUpdateConfiguration() {
287297
this._onDidChangeConfiguration.fire(undefined);
288298
}

0 commit comments

Comments
 (0)