Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Exclude prerelease tagged versions when fetching latest gopls version (
Browse files Browse the repository at this point in the history
  • Loading branch information
stamblerre authored and ramya-rao-a committed Nov 5, 2019
1 parent 2bb53a5 commit e936903
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,19 @@ async function latestGopls(tool: Tool): Promise<semver.SemVer> {
// Coerce the versions into SemVers so that they can be sorted correctly.
const versions = [];
for (const version of data.trim().split('\n')) {
versions.push(semver.coerce(version));
const parsed = semver.parse(version, {
includePrerelease: true,
loose: true,
});
versions.push(parsed);
}
if (versions.length === 0) {
return null;
}
versions.sort(semver.rcompare);
return versions[0];

// The first version in the sorted list without a prerelease tag.
return versions.find(version => !version.prerelease || !version.prerelease.length);
}

async function goplsVersion(goplsPath: string): Promise<string> {
Expand Down Expand Up @@ -594,7 +600,7 @@ async function goProxyRequest(tool: Tool, endpoint: string): Promise<any> {
return null;
}

function goProxy(): string[] {
function goProxy(): string[] {
const output: string = process.env['GOPROXY'];
if (!output || !output.trim()) {
return [];
Expand Down

0 comments on commit e936903

Please sign in to comment.