diff --git a/go_modules/helpers/go.mod b/go_modules/helpers/go.mod index 56cf3f640a..dafd260f8b 100644 --- a/go_modules/helpers/go.mod +++ b/go_modules/helpers/go.mod @@ -2,8 +2,4 @@ module github.com/dependabot/dependabot-core/go_modules/helpers go 1.16 -require ( - github.com/Masterminds/vcs v1.13.1 - github.com/dependabot/gomodules-extracted v1.4.2 - golang.org/x/mod v0.5.1 -) +require github.com/Masterminds/vcs v1.13.1 diff --git a/go_modules/helpers/go.sum b/go_modules/helpers/go.sum index dcd6cdb6e9..240000ee2c 100644 --- a/go_modules/helpers/go.sum +++ b/go_modules/helpers/go.sum @@ -1,20 +1,2 @@ github.com/Masterminds/vcs v1.13.1 h1:NL3G1X7/7xduQtA2sJLpVpfHTNBALVNSjob6KEjPXNQ= github.com/Masterminds/vcs v1.13.1/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA= -github.com/dependabot/gomodules-extracted v1.4.2 h1:3IxvHARuuSojSNUHguc6kzWgs+uQN3fdRCowJMU1kDE= -github.com/dependabot/gomodules-extracted v1.4.2/go.mod h1:cpzrmDX1COyhSDQXHfkRMw0STb0vmguBFqmrkr51h1I= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e h1:aZzprAO9/8oim3qStq3wc1Xuxx4QmAGriC4VU4ojemQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/go_modules/helpers/main.go b/go_modules/helpers/main.go index f146b30692..4f8d6e8747 100644 --- a/go_modules/helpers/main.go +++ b/go_modules/helpers/main.go @@ -7,7 +7,6 @@ import ( "os" "github.com/dependabot/dependabot-core/go_modules/helpers/importresolver" - "github.com/dependabot/dependabot-core/go_modules/helpers/updatechecker" ) type HelperParams struct { @@ -32,10 +31,6 @@ func main() { funcErr error ) switch helperParams.Function { - case "getVersions": - var args updatechecker.Args - parseArgs(helperParams.Args, &args) - funcOut, funcErr = updatechecker.GetVersions(&args) case "getVcsRemoteForImport": var args importresolver.Args parseArgs(helperParams.Args, &args) diff --git a/go_modules/helpers/updatechecker/main.go b/go_modules/helpers/updatechecker/main.go deleted file mode 100644 index 9689da08d6..0000000000 --- a/go_modules/helpers/updatechecker/main.go +++ /dev/null @@ -1,93 +0,0 @@ -package updatechecker - -import ( - "context" - "errors" - "io/ioutil" - - "github.com/dependabot/gomodules-extracted/cmd/go/_internal_/modfetch" - "github.com/dependabot/gomodules-extracted/cmd/go/_internal_/modload" - "golang.org/x/mod/modfile" - "golang.org/x/mod/semver" -) - -type Dependency struct { - Name string `json:"name"` - Version string `json:"version"` -} - -type Args struct { - Dependency *Dependency `json:"dependency"` -} - -// GetVersions returns a list of versions for the given dependency that -// are within the same major version. -func GetVersions(args *Args) (interface{}, error) { - if args.Dependency == nil { - return nil, errors.New("Expected args.dependency to not be nil") - } - - currentVersion := args.Dependency.Version - - modload.DisallowWriteGoMod() - _ = modload.LoadModFile(context.Background()) - - repo := modfetch.Lookup("direct", args.Dependency.Name) - versions, err := repo.Versions("") - if err != nil { - return nil, err - } - - excludes, err := goModExcludes(args.Dependency.Name) - if err != nil { - return nil, err - } - - currentMajor := semver.Major(currentVersion) - - var candidateVersions []string - -Outer: - for _, v := range versions { - if semver.Major(v) != currentMajor { - continue - } - - for _, exclude := range excludes { - if v == exclude { - continue Outer - } - } - - candidateVersions = append(candidateVersions, v) - } - - return candidateVersions, nil -} - -func goModExcludes(dependency string) ([]string, error) { - data, err := ioutil.ReadFile("go.mod") - if err != nil { - return nil, err - } - - var f *modfile.File - // TODO library detection - don't consider exclude etc for libraries - if "library" == "true" { - f, err = modfile.ParseLax("go.mod", data, nil) - } else { - f, err = modfile.Parse("go.mod", data, nil) - } - if err != nil { - return nil, err - } - - var excludes []string - for _, e := range f.Exclude { - if e.Mod.Path == dependency { - excludes = append(excludes, e.Mod.Version) - } - } - - return excludes, nil -}