Fix fetching repositories with repo root relative tags

This commit is contained in:
adisbladis 2020-07-20 15:42:52 +02:00
parent 85684cb652
commit 634635dc70
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7

View file

@ -9,6 +9,7 @@ import (
"io/ioutil"
"os/exec"
"sort"
"strings"
)
type packageJob struct {
@ -138,7 +139,21 @@ func fetchPackage(importPath string, goPackagePath string, rev string) (*types.P
"--url", repoRoot.Repo,
"--rev", rev).Output()
if err != nil {
return nil, err
// It's a relatively common idiom to tag storage/v1.0.0
newRev := fmt.Sprintf("%s/%s", strings.TrimPrefix(goPackagePath, repoRoot.Root+"/"), rev)
originalErr := err
stdout, err = exec.Command(
"nix-prefetch-git",
"--quiet",
"--fetch-submodules",
"--url", repoRoot.Repo,
"--rev", newRev).Output()
if err != nil {
return nil, originalErr
}
rev = newRev
}
var output *prefetchOutput