Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Special case vbom.ml packages. Fixes #1169 #1171

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion internal/gps/deduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ var (
svnSchemes = []string{"https", "http", "svn", "svn+ssh"}
)

const gopkgUnstableSuffix = "-unstable"
const (
gopkgUnstableSuffix = "-unstable"
vbomUtilPkg = "vbom.ml/util"
)

func validateVCSScheme(scheme, typ string) bool {
// everything allows plain ssh
Expand Down Expand Up @@ -91,6 +94,7 @@ func pathDeducerTrie() *deducerTrie {
dxt.Insert("git.launchpad.net/", launchpadGitDeducer{regexp: glpRegex})
dxt.Insert("hub.jazz.net/", jazzDeducer{regexp: jazzRegex})
dxt.Insert("git.apache.org/", apacheDeducer{regexp: apacheRegex})
dxt.Insert("vbom.ml/", vbomDeducer{})

return dxt
}
Expand Down Expand Up @@ -539,6 +543,33 @@ func (m vcsExtensionDeducer) deduceSource(path string, u *url.URL) (maybeSource,
}
}

type vbomDeducer struct{}

func (m vbomDeducer) deduceRoot(path string) (string, error) {
if !strings.HasPrefix(path, vbomUtilPkg) {
return "", fmt.Errorf("%s is not %s package", path, vbomUtilPkg)
}
return vbomUtilPkg, nil
}

func (m vbomDeducer) deduceSource(path string, u *url.URL) (maybeSource, error) {
if !strings.HasPrefix(path, vbomUtilPkg) {
return nil, fmt.Errorf("%s is not %s package", path, vbomUtilPkg)
}

if u.Scheme != "" {
if !validateVCSScheme(u.Scheme, "git") {
return nil, fmt.Errorf("%s is not a valid scheme for accessing a git repository", u.Scheme)
}
return maybeGitSource{url: u}, nil
}

u.Scheme = "https"
u.Host = "github.com"
u.Path = "/fvbommel/util.git"
return maybeGitSource{url: u}, nil
}

// A deducer takes an import path and inspects it to determine where the
// corresponding project root should be. It applies a number of matching
// techniques, eventually falling back to an HTTP request for go-get metadata if
Expand Down