Skip to content

Commit cfc795c

Browse files
committed
Revert "extension/src/welcome: fix 'go.showWelcome' setting interpretation"
This reverts commit f8173bc. Reason: broke the welcome page suppression based on isInCloudIDE Change-Id: If042f5269754f7dd6cb4c1b2473979d5e11247b3 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/581117 Commit-Queue: Hyang-Ah Hana Kim <[email protected]> kokoro-CI: kokoro <[email protected]> Reviewed-by: Peter Weinberger <[email protected]>
1 parent d0d95ab commit cfc795c

File tree

2 files changed

+44
-61
lines changed

2 files changed

+44
-61
lines changed

extension/src/welcome.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import path = require('path');
1212
import semver = require('semver');
1313
import { extensionId } from './const';
1414
import { GoExtensionContext } from './context';
15-
import { extensionInfo, getGoConfig } from './config';
15+
import { extensionInfo } from './config';
1616
import { getFromGlobalState, updateGlobalState } from './stateUtils';
1717
import { createRegisterCommand } from './commands';
1818

@@ -29,7 +29,11 @@ export class WelcomePanel {
2929
}
3030
});
3131
}
32-
showGoWelcomePage();
32+
33+
// Show the Go welcome page on update.
34+
if (!extensionInfo.isInCloudIDE && vscode.workspace.getConfiguration('go.showWelcome')) {
35+
showGoWelcomePage();
36+
}
3337
}
3438

3539
public static currentPanel: WelcomePanel | undefined;
@@ -274,9 +278,6 @@ function showGoWelcomePage() {
274278
}
275279

276280
export function shouldShowGoWelcomePage(showVersions: string[], newVersion: string, oldVersion: string): boolean {
277-
if (!extensionInfo.isInCloudIDE && getGoConfig().get('showWelcome') === false) {
278-
return false;
279-
}
280281
if (newVersion === oldVersion) {
281282
return false;
282283
}

extension/test/integration/welcome.test.ts

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,70 +8,52 @@ import assert from 'assert';
88
import { shouldShowGoWelcomePage } from '../../src/welcome';
99
import { extensionId } from '../../src/const';
1010
import { WelcomePanel } from '../../src/welcome';
11-
import sinon = require('sinon');
12-
import * as config from '../../src/config';
13-
import { MockCfg } from '../mocks/MockCfg';
1411

1512
suite('WelcomePanel Tests', () => {
16-
let sandbox: sinon.SinonSandbox;
17-
setup(() => {
18-
sandbox = sinon.createSandbox();
19-
});
20-
teardown(() => sandbox.restore());
21-
22-
// 0:showVersions, 1:newVersion, 2:oldVersion, 3: showWelcome, 4:expected
23-
//
24-
// If showWelcome is false, then expected has to be false.
25-
// Otherwise, expected is true if (and only if) newVersion occurs in showVersions
26-
// and is newer than oldVersion (as semantic versions).
27-
type testCase = [string[], string, string, boolean, boolean];
13+
// 0:showVersions, 1:newVersion, 2:oldVersion, 3:expected
14+
type testCase = [string[], string, string, boolean];
2815
const testCases: testCase[] = [
29-
[[], '0.22.0', '0.0.0', true, false],
30-
[[], '0.22.0', '0.21.0', true, false],
31-
[[], '0.22.0', '0.22.0-rc.1', true, false],
32-
[[], '0.22.0', '0.22.0', true, false],
33-
[[], '0.22.0', '0.23.0', true, false],
16+
[[], '0.22.0', '0.0.0', false],
17+
[[], '0.22.0', '0.21.0', false],
18+
[[], '0.22.0', '0.22.0-rc.1', false],
19+
[[], '0.22.0', '0.22.0', false],
20+
[[], '0.22.0', '0.23.0', false],
3421

35-
[['0.22.0'], '0.22.0', '0.0.0', true, true],
36-
[['0.22.0'], '0.22.0', '0.0.0', false, false],
37-
[['0.22.0'], '0.22.0', '0.21.0-rc.1', true, true],
38-
[['0.22.0'], '0.22.0', '0.21.0', true, true],
39-
[['0.22.0'], '0.22.0', '0.22.0-rc.1', true, true],
40-
[['0.22.0'], '0.22.0', '0.22.0', true, false],
41-
[['0.22.0'], '0.22.0', '0.22.1', true, false],
42-
[['0.22.0'], '0.22.0', '0.23.0', true, false],
43-
[['0.22.0'], '0.22.0', '1.0.0', true, false],
44-
[['0.22.0'], '0.22.0', '2021.1.100', true, false],
22+
[['0.22.0'], '0.22.0', '0.0.0', true],
23+
[['0.22.0'], '0.22.0', '0.21.0-rc.1', true],
24+
[['0.22.0'], '0.22.0', '0.21.0', true],
25+
[['0.22.0'], '0.22.0', '0.22.0-rc.1', true],
26+
[['0.22.0'], '0.22.0', '0.22.0', false],
27+
[['0.22.0'], '0.22.0', '0.22.1', false],
28+
[['0.22.0'], '0.22.0', '0.23.0', false],
29+
[['0.22.0'], '0.22.0', '1.0.0', false],
30+
[['0.22.0'], '0.22.0', '2021.1.100', false],
4531

46-
[['0.22.0'], '0.22.0-rc.2', '0.0.0', true, true],
47-
[['0.22.0'], '0.22.0-rc.2', '0.21.0-rc.1', true, true],
48-
[['0.22.0'], '0.22.0-rc.2', '0.21.0', true, true],
49-
[['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.1', true, true],
50-
[['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.2', true, false],
51-
[['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.3', true, true],
52-
[['0.22.0'], '0.22.0-rc.2', '0.22.0', true, true],
53-
[['0.22.0'], '0.22.0-rc.2', '0.22.1', true, false],
54-
[['0.22.0'], '0.22.0-rc.2', '0.23.0', true, false],
55-
[['0.22.0'], '0.22.0-rc.2', '1.0.0', true, false],
56-
[['0.22.0'], '0.22.0-rc.2', '2021.1.100', true, false],
32+
[['0.22.0'], '0.22.0-rc.2', '0.0.0', true],
33+
[['0.22.0'], '0.22.0-rc.2', '0.21.0-rc.1', true],
34+
[['0.22.0'], '0.22.0-rc.2', '0.21.0', true],
35+
[['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.1', true],
36+
[['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.2', false],
37+
[['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.3', true],
38+
[['0.22.0'], '0.22.0-rc.2', '0.22.0', true],
39+
[['0.22.0'], '0.22.0-rc.2', '0.22.1', false],
40+
[['0.22.0'], '0.22.0-rc.2', '0.23.0', false],
41+
[['0.22.0'], '0.22.0-rc.2', '1.0.0', false],
42+
[['0.22.0'], '0.22.0-rc.2', '2021.1.100', false],
5743

58-
[['0.22.0'], '0.22.1', '0.0.0', true, false],
59-
[['0.22.0'], '0.22.1', '0.21.0-rc.1', true, false],
60-
[['0.22.0'], '0.22.1', '0.21.0', true, false],
61-
[['0.22.0'], '0.22.1', '0.22.0-rc.1', true, false],
62-
[['0.22.0'], '0.22.1', '0.22.0', true, false],
63-
[['0.22.0'], '0.22.1', '0.23.0', true, false],
64-
[['0.22.0'], '0.22.1', '1.0.0', true, false],
65-
[['0.22.0'], '0.22.1', '2021.1.100', true, false]
44+
[['0.22.0'], '0.22.1', '0.0.0', false],
45+
[['0.22.0'], '0.22.1', '0.21.0-rc.1', false],
46+
[['0.22.0'], '0.22.1', '0.21.0', false],
47+
[['0.22.0'], '0.22.1', '0.22.0-rc.1', false],
48+
[['0.22.0'], '0.22.1', '0.22.0', false],
49+
[['0.22.0'], '0.22.1', '0.23.0', false],
50+
[['0.22.0'], '0.22.1', '1.0.0', false],
51+
[['0.22.0'], '0.22.1', '2021.1.100', false]
6652
];
6753
testCases.forEach((c: testCase) => {
68-
const [showVersions, newVersion, oldVersion, showWelcome, expected] = c;
69-
test(`shouldShowGoWelcomePage(${JSON.stringify(
70-
showVersions
71-
)}, ${newVersion}, ${oldVersion}, (showWelcome=${showWelcome}))`, () => {
72-
const goConfig = new MockCfg([]);
73-
sandbox.stub(config, 'getGoConfig').returns(goConfig);
74-
sinon.stub(goConfig, 'get').withArgs('showWelcome').returns(showWelcome);
54+
const [showVersions, newVersion, oldVersion, expected] = c;
55+
56+
test(`shouldShowGoWelcomePage(${JSON.stringify(showVersions)}, ${newVersion}, ${oldVersion})`, () => {
7557
assert.strictEqual(shouldShowGoWelcomePage(showVersions, newVersion, oldVersion), expected);
7658
});
7759
});

0 commit comments

Comments
 (0)