Skip to content

Commit

Permalink
src/config: set ExtensionInfo.isPreview for prerelease
Browse files Browse the repository at this point in the history
Odd number minor version implies prerelease.

For #1935

Change-Id: I6cf4c4673b3a70609c45a17ce7ee0b92dca6ce5b
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/595382
Commit-Queue: Hyang-Ah Hana Kim <[email protected]>
kokoro-CI: kokoro <[email protected]>
Reviewed-by: Hongxiang Jiang <[email protected]>
  • Loading branch information
hyangah committed Aug 20, 2024
1 parent d8d6e05 commit a83a369
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions extension/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*--------------------------------------------------------*/

import vscode = require('vscode');
import semver = require('semver');
import { extensionId } from './const';

/** getGoConfig is declared as an exported const rather than a function, so it can be stubbbed in testing. */
Expand Down Expand Up @@ -34,16 +35,21 @@ export class ExtensionInfo {
readonly version?: string;
/** The application name of the editor, like 'VS Code' */
readonly appName: string;
/** True if the extension runs in preview mode (e.g. Nightly) */
/** True if the extension runs in preview mode (e.g. Nightly, prerelease) */
readonly isPreview: boolean;
/** True if the extension runs in well-kwnon cloud IDEs */
readonly isInCloudIDE: boolean;

constructor() {
const packageJSON = vscode.extensions.getExtension(extensionId)?.packageJSON;
this.version = packageJSON?.version;
const version = semver.parse(packageJSON?.version);
this.version = version?.format();
this.appName = vscode.env.appName;
this.isPreview = !!packageJSON?.preview;

// golang.go-nightly: packageJSON.preview is true.
// golang.go prerelease: minor version is an odd number.
this.isPreview =
!!packageJSON?.preview || !!(extensionId === 'golang.go' && version && version.minor % 2 === 1);
this.isInCloudIDE =
process.env.CLOUD_SHELL === 'true' ||
process.env.MONOSPACE_ENV === 'true' ||
Expand Down

0 comments on commit a83a369

Please sign in to comment.