Remove vcs package since its behaviour diverges from cmd/go.

As stated in the issue https://github.com/golang/go/issues/11490
the package 'vcs' diverges significantly from cmd/go import path resolution
behaviour and thus needs to be removed for goreportcard to support
modules and versioning.
See also: https://golang.org/cl/159818.
This commit is contained in:
Nicolò Santamaria
2022-02-05 15:06:57 +01:00
committed by Shawn Smith
parent d35b037bad
commit e6fde6c851
9 changed files with 5 additions and 982 deletions

View File

@@ -1,24 +1,13 @@
package download
import (
"errors"
"strings"
"golang.org/x/tools/go/vcs"
)
// Clean trims any URL parts, like the scheme or username, that might be present
// in a user-submitted URL
func Clean(path string) (string, error) {
importPath := trimUsername(trimScheme(path))
root, err := vcs.RepoRootForImportPath(importPath, true)
if err != nil {
return "", err
}
if root != nil && (root.Root == "" || root.Repo == "") {
return root.Root, errors.New("empty repo root")
}
return root.Root, err
func Clean(path string) string {
return trimUsername(trimScheme(path))
}
// trimScheme removes a scheme (e.g. https://) from the URL for more