summaryrefslogtreecommitdiff
path: root/clone.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-15 12:14:22 -0600
committerJeff Carr <[email protected]>2024-12-15 12:14:22 -0600
commitbab2506d348a634ad35f81a09675c9beed493d2b (patch)
tree799b8bcadd628af1f856811512db31c1389c0dc2 /clone.go
parentb3bfa8915c1cc39bb36094829273d43621eb39ee (diff)
trying to fix clonev0.6.28
Diffstat (limited to 'clone.go')
-rw-r--r--clone.go56
1 files changed, 33 insertions, 23 deletions
diff --git a/clone.go b/clone.go
index 4c7cac9..4c1a1ac 100644
--- a/clone.go
+++ b/clone.go
@@ -32,31 +32,9 @@ func clone(gopath string) (*gitpb.Repo, error) {
return nil, err
}
- // first try to generate go.mod & go.sum with go-mod-clean
- if err := pb.ValidGoSum(); err != nil {
- // update go.sum and go.mod
- if err := pb.RunStrict([]string{"go-mod-clean"}); err != nil {
- log.Info("")
- log.Info("Do you have go-mod-clean? Otherwise:")
- log.Info(" go install go.wit.com/apps/go-mod-clean@latest")
- log.Info("")
- }
- }
- // if this fails, just use go mod
- if err := pb.ValidGoSum(); err != nil {
- if err := pb.RunStrict([]string{"go", "mod", "init", pb.GoPath}); err != nil {
- log.Info("go mod init failed", err)
- }
- if err := pb.RunStrict([]string{"go", "mod", "tidy"}); err != nil {
- log.Info("go mod tidy failed", err)
- }
- }
- if err := pb.ValidGoSum(); err != nil {
- // have to give up. can't recursive clone without go.mod file
- log.Info("could not generate valid go.sum file")
+ if err := makeValidGoSum(pb); err != nil {
return nil, err
}
- pb.ParseGoSum()
// double check it actually downloaded
fullgitdir := filepath.Join(forge.GetGoSrc(), gopath, ".git")
@@ -128,3 +106,35 @@ func recursiveClone(check *gitpb.Repo) error {
}
return nil
}
+
+func makeValidGoSum(check *gitpb.Repo) error {
+ // first try to generate go.mod & go.sum with go-mod-clean
+ if err := check.ValidGoSum(); err != nil {
+ log.Info("try running go-mod-clean")
+ // update go.sum and go.mod
+ if err := check.RunStrict([]string{"go-mod-clean"}); err != nil {
+ log.Info("")
+ log.Info("Do you have go-mod-clean? Otherwise:")
+ log.Info(" go install go.wit.com/apps/go-mod-clean@latest")
+ log.Info("")
+ }
+ }
+ // if this fails, just use go mod
+ if err := check.ValidGoSum(); err != nil {
+ cmd := []string{"go", "mod", "init", check.GoPath}
+ log.Info("try running", cmd)
+ if err := check.RunStrict(cmd); err != nil {
+ log.Info("go mod init failed", err)
+ }
+ if err := check.RunStrict([]string{"go", "mod", "tidy"}); err != nil {
+ log.Info("go mod tidy failed", err)
+ }
+ }
+ if err := check.ValidGoSum(); err != nil {
+ // have to give up. can't recursive clone without go.mod file
+ log.Info("could not generate valid go.sum file")
+ return err
+ }
+ check.ParseGoSum()
+ return nil
+}