Skip to content

Commit

Permalink
src/goInstallTools: pin dlv-dap version @2f136727
Browse files Browse the repository at this point in the history
This reverts commit a1cc5e5
(https://go-review.googlesource.com/c/vscode-go/+/344789)

and pins dlv-dap at go-delve/delve@2f13672

We removed pinning in a1cc5e5 because we were still actively developing
Delve DAP and the pinning made it difficult for users to pick up
the latest bug fixes.

Now Delve DAP is stable and most critical features are ready.
Let's pin the version again and prevent breakages.

We don't update the latestVersion in this change -
currently dlv-dap uses this as the minimum required version.

Updates #1850
Updates #1661

Change-Id: Ib8af635f3ee431bffa1fc505f85c9a87604f8323
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/370414
Trust: Hyang-Ah Hana Kim <[email protected]>
Reviewed-by: Polina Sokolova <[email protected]>
  • Loading branch information
hyangah committed Dec 8, 2021
1 parent bf2ce37 commit 27bcdca
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/goToolsInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
replacedByGopls: false,
isImportant: true,
description: 'Go debugger & debug adapter (Delve DAP)',
defaultVersion: 'master', // Always build from the master.
defaultVersion: '2f13672765fe', // pinned version
minimumGoVersion: semver.coerce('1.12'), // dlv requires 1.12+ for build
latestVersion: semver.parse('v1.7.3-0.20211026171155-b48ceec161d5'),
latestVersionTimestamp: moment('2021-10-26', 'YYYY-MM-DD')
Expand Down
4 changes: 2 additions & 2 deletions test/integration/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ suite('Installation Tests', function () {
{ name: 'guru', versions: ['v1.0.0'], wantVersion: 'v1.0.0' },
{
name: 'dlv-dap',
versions: ['v1.0.0', 'master'],
versions: ['v1.0.0', getTool('dlv-dap').defaultVersion!],
wantVersion: 'v' + getTool('dlv-dap').latestVersion!.toString()
}
],
Expand All @@ -175,7 +175,7 @@ suite('Installation Tests', function () {
{ name: 'guru', versions: ['v1.0.0'], wantVersion: 'v1.0.0' },
{
name: 'dlv-dap',
versions: ['v1.0.0', 'master'],
versions: ['v1.0.0', getTool('dlv-dap').defaultVersion!],
wantVersion: 'v' + getTool('dlv-dap').latestVersion!.toString()
}
],
Expand Down
2 changes: 1 addition & 1 deletion tools/allTools.ts.in
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const allToolsInformation: { [key: string]: Tool } = {
replacedByGopls: false,
isImportant: true,
description: 'Go debugger & debug adapter (Delve DAP)',
defaultVersion: 'master', // Always build from the master.
defaultVersion: '%s', // pinned version
minimumGoVersion: semver.coerce('1.12'), // dlv requires 1.12+ for build
latestVersion: semver.parse('%s'),
latestVersionTimestamp: moment('%s', 'YYYY-MM-DD')
Expand Down
26 changes: 25 additions & 1 deletion tools/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package main
import (
"bytes"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
Expand All @@ -23,6 +24,7 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strings"

Expand Down Expand Up @@ -235,6 +237,12 @@ func main() {
if err != nil {
log.Fatal(err)
}
// Due to https://github.com/golang/vscode-go/issues/1682, we cannot use
// pseudo-version as the pinned version reliably.
dlvRevOrStable := dlvVersion.Version
if rev, err := pseudoVersionRev(dlvVersion.Version); err == nil { // pseudo-version
dlvRevOrStable = rev
}

// Check for the latest gopls version.
versions, err := listAllModuleVersions("golang.org/x/tools/gopls")
Expand Down Expand Up @@ -269,7 +277,7 @@ func main() {
}

// TODO(suzmue): change input to json and avoid magic string printing.
toolsString := fmt.Sprintf(string(data), goplsVersion.Version, goplsVersion.Time[:len("YYYY-MM-DD")], goplsVersionPre.Version, goplsVersionPre.Time[:len("YYYY-MM-DD")], dlvVersion.Version, dlvVersion.Time[:len("YYYY-MM-DD")])
toolsString := fmt.Sprintf(string(data), goplsVersion.Version, goplsVersion.Time[:len("YYYY-MM-DD")], goplsVersionPre.Version, goplsVersionPre.Time[:len("YYYY-MM-DD")], dlvRevOrStable, dlvVersion.Version, dlvVersion.Time[:len("YYYY-MM-DD")])

// Write tools section.
b.WriteString(toolsString)
Expand Down Expand Up @@ -685,3 +693,19 @@ func describeDebugProperty(p *Property) string {
}
return b.String()
}

// pseudoVersionRev extracts the revision info if the given version is pseudo version.
// We wanted to use golang.org/x/mod/module.PseudoVersionRev, but couldn't due to
// an error in the CI. This is a workaround.
//
// It assumes the version string came from the proxy, so a valid, canonical version
// string. Thus, the check for pseudoversion is not as robust as golang.org/x/mod/module
// offers.
func pseudoVersionRev(ver string) (rev string, _ error) {
var pseudoVersionRE = regexp.MustCompile(`^v[0-9]+\.(0\.0-|\d+\.\d+-([^+]*\.)?0\.)\d{14}-[A-Za-z0-9]+(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$`)
if strings.Count(ver, "-") < 2 || !pseudoVersionRE.MatchString(ver) {
return "", errors.New("not a pseudo version")
}
j := strings.LastIndex(ver, "-")
return ver[j+1:], nil
}

0 comments on commit 27bcdca

Please sign in to comment.