From 73e7c369ddeac7017de44fb9d16752fa3d764410 Mon Sep 17 00:00:00 2001 From: Hana Date: Wed, 17 Mar 2021 22:21:05 -0400 Subject: [PATCH] src/goLanguageServer: always check the version before crash report 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 golang/vscode-go#1300 Updates golang/vscode-go#1334 Updates golang/vscode-go#1338 Change-Id: I9965297b164665056dbec68285eb740ec2908f01 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/302832 Trust: Hyang-Ah Hana Kim Run-TryBot: Hyang-Ah Hana Kim TryBot-Result: kokoro Reviewed-by: Rebecca Stambler --- src/goInstallTools.ts | 3 +-- src/goLanguageServer.ts | 13 ++++++++++--- src/goTools.ts | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index 79a9bd6cc0..197d6e45f7 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -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']; diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts index ee68ab982b..3d2adfc9c0 100644 --- a/src/goLanguageServer.ts +++ b/src/goLanguageServer.ts @@ -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 { +export async function shouldUpdateLanguageServer( + tool: Tool, + cfg: LanguageServerConfig, + mustCheck?: boolean +): Promise { // 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; } @@ -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; @@ -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 @@ -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} diff --git a/src/goTools.ts b/src/goTools.ts index d6708eb700..ff921c6ab7 100644 --- a/src/goTools.ts +++ b/src/goTools.ts @@ -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',