Skip to content

Commit a83a369

Browse files
committed
src/config: set ExtensionInfo.isPreview for prerelease
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]>
1 parent d8d6e05 commit a83a369

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

extension/src/config.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*--------------------------------------------------------*/
66

77
import vscode = require('vscode');
8+
import semver = require('semver');
89
import { extensionId } from './const';
910

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

4243
constructor() {
4344
const packageJSON = vscode.extensions.getExtension(extensionId)?.packageJSON;
44-
this.version = packageJSON?.version;
45+
const version = semver.parse(packageJSON?.version);
46+
this.version = version?.format();
4547
this.appName = vscode.env.appName;
46-
this.isPreview = !!packageJSON?.preview;
48+
49+
// golang.go-nightly: packageJSON.preview is true.
50+
// golang.go prerelease: minor version is an odd number.
51+
this.isPreview =
52+
!!packageJSON?.preview || !!(extensionId === 'golang.go' && version && version.minor % 2 === 1);
4753
this.isInCloudIDE =
4854
process.env.CLOUD_SHELL === 'true' ||
4955
process.env.MONOSPACE_ENV === 'true' ||

0 commit comments

Comments
 (0)