From 634635dc7056870528afdb6dbe7a4d09f9715919 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 20 Jul 2020 15:42:52 +0200 Subject: [PATCH] Fix fetching repositories with repo root relative tags --- fetch/fetch.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/fetch/fetch.go b/fetch/fetch.go index b8f21ef..a6d2501 100644 --- a/fetch/fetch.go +++ b/fetch/fetch.go @@ -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