Skip to content

Commit

Permalink
src/goLanguageServer: always check the version before crash report
Browse files Browse the repository at this point in the history
For dev-version, we still not enforce update (this case should be
clear enough to tell apart from the gopls version included in the
issue report and is valuable to detect crash report during dev
period).

And
 - Add go version used by the extension and the update flag info.
 - Update gopls latestVersion to v0.6.8.

Updates #1300
Updates #1334
Updates #1338

Change-Id: I9965297b164665056dbec68285eb740ec2908f01
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/302832
Trust: Hyang-Ah Hana Kim <[email protected]>
Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Rebecca Stambler <[email protected]>
  • Loading branch information
hyangah committed Mar 18, 2021
1 parent 9a9a216 commit 73e7c36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ export async function installTool(
const execFile = util.promisify(cp.execFile);
const { stdout, stderr } = await execFile(goBinary, args, opts);
output = `${stdout} ${stderr}`;
logVerbose('install: %s %s\n%s%s', goBinary, args.join(' '), stdout, stderr);

logVerbose(`install: ${goBinary} ${args.join(' ')}\n${stdout}${stderr}`);
if (hasModSuffix(tool) || tool.name === 'dlv-dap') {
// Actual installation of the -gomod tool and dlv-dap is done by running go build.
const gopath = env['GOBIN'] || env['GOPATH'];
Expand Down
13 changes: 10 additions & 3 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,9 +1008,13 @@ function allFoldersHaveSameGopath(): boolean {
return vscode.workspace.workspaceFolders.find((x) => tempGopath !== getCurrentGoPath(x.uri)) ? false : true;
}

export async function shouldUpdateLanguageServer(tool: Tool, cfg: LanguageServerConfig): Promise<semver.SemVer> {
export async function shouldUpdateLanguageServer(
tool: Tool,
cfg: LanguageServerConfig,
mustCheck?: boolean
): Promise<semver.SemVer> {
// Only support updating gopls for now.
if (tool.name !== 'gopls' || cfg.checkForUpdates === 'off' || IsInCloudIDE) {
if (tool.name !== 'gopls' || (!mustCheck && (cfg.checkForUpdates === 'off' || IsInCloudIDE))) {
return null;
}

Expand Down Expand Up @@ -1488,7 +1492,7 @@ async function suggestGoplsIssueReport(
// just prompt them to update, not file an issue.
const tool = getTool('gopls');
if (tool) {
const versionToUpdate = await shouldUpdateLanguageServer(tool, latestConfig);
const versionToUpdate = await shouldUpdateLanguageServer(tool, latestConfig, true);
if (versionToUpdate) {
promptForUpdatingTool(tool.name, versionToUpdate, true);
return;
Expand Down Expand Up @@ -1567,6 +1571,7 @@ You will be asked to provide additional information and logs, so PLEASE READ THE
// Get the user's version in case the update prompt above failed.
const usersGoplsVersion = await getLocalGoplsVersion(latestConfig);
const extInfo = getExtensionInfo();
const goVersion = await getGoVersion();
const settings = latestConfig.flags.join(' ');
const title = `gopls: automated issue report (${errKind})`;
const goplsLog = sanitizedLog
Expand All @@ -1583,7 +1588,9 @@ Failed to auto-collect gopls trace: ${failureReason}.
const body = `
gopls version: ${usersGoplsVersion}
gopls flags: ${settings}
update flags: ${latestConfig.checkForUpdates}
extension version: ${extInfo.version}
go version: ${goVersion?.format(true)}
environment: ${extInfo.appName} ${process.platform}
initialization error: ${initializationError}
manual restart count: ${manualRestartCount}
Expand Down
8 changes: 4 additions & 4 deletions src/goTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ export const allToolsInformation: { [key: string]: Tool } = {
description: 'Language Server from Google',
usePrereleaseInPreviewMode: true,
minimumGoVersion: semver.coerce('1.12'),
latestVersion: semver.coerce('0.6.6'),
latestVersionTimestamp: moment('2021-02-22', 'YYYY-MM-DD'),
latestPrereleaseVersion: semver.coerce('0.6.6'),
latestPrereleaseVersionTimestamp: moment('2021-02-22', 'YYYY-MM-DD')
latestVersion: semver.coerce('0.6.8'),
latestVersionTimestamp: moment('2021-03-17', 'YYYY-MM-DD'),
latestPrereleaseVersion: semver.coerce('0.6.8'),
latestPrereleaseVersionTimestamp: moment('2021-03-17', 'YYYY-MM-DD')
},
'dlv': {
name: 'dlv',
Expand Down

0 comments on commit 73e7c36

Please sign in to comment.