Skip to content

Commit

Permalink
Merge pull request #3 from rminnich/fixreplace
Browse files Browse the repository at this point in the history
Fix up replace directives
  • Loading branch information
floren authored Sep 2, 2021
2 parents 9e38f03 + 230c8eb commit 37bdad3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/pkg/bb/bb.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,25 @@ func dealWithDeps(env golang.Environ, bbDir, tmpDir, pkgDir string, mainPkgs []*
if err := mod.AddReplace(mpath, "", path.Join("..", "..", mpath), ""); err != nil {
return fmt.Errorf("could not add replace rule for %v to go.mod: %v", mpath, err)
}
// Also copy over every replace directive
if module.GoMod != "" {
gomodData, err := ioutil.ReadFile(module.GoMod)
if err != nil {
return err
}
gomod, err := modfile.Parse(module.GoMod, gomodData, nil)
if err != nil {
return err
}
for _, r := range gomod.Replace {
if strings.HasPrefix(r.New.Path, "./") || strings.HasPrefix(r.New.Path, "../") || strings.HasPrefix(r.New.Path, "/") {
continue
}
if err := mod.AddReplace(r.Old.Path, r.Old.Version, r.New.Path, r.New.Version); err != nil {
return err
}
}
}
}

gomod, err := mod.Format()
Expand Down

0 comments on commit 37bdad3

Please sign in to comment.