summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clone.go49
1 files changed, 27 insertions, 22 deletions
diff --git a/clone.go b/clone.go
index ca6be35..9b5ec33 100644
--- a/clone.go
+++ b/clone.go
@@ -55,15 +55,17 @@ func recursiveClone(check *gitpb.Repo) error {
}
log.Info("STARTING RECURSIVE CLONE", check.GetGoPath())
log.Info("STARTING RECURSIVE CLONE", check.GetGoPath())
- if check.GoInfo.GoPrimitive {
- log.Info("repo is a primitive", check.GetGoPath())
+ // if just cloned, parse the go.sum file for deps
+ if check.ParseGoSum() {
+ } else {
+ makeValidGoSum(check)
+ }
+ if check.GetGoPrimitive() {
// go primitive repos are "pure"
+ log.Info("repo is primitive", check.GetGoPath())
return nil
}
- // if just cloned, parse the go.sum file for deps
- check.ParseGoSum()
-
if check.GoDeps == nil {
log.Info("repo godeps == nil", check.GetGoPath())
return errors.New("go.sum is missing?")
@@ -108,17 +110,23 @@ func makeValidGoSum(check *gitpb.Repo) error {
// attempt to grab the notes
check.Run([]string{"git", "fetch", "origin", "refs/notes/*:refs/notes/*"})
- // 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 check.ParseGoSum() {
+ return 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 check.ParseGoSum() {
+ return nil
+ }
+
// if this fails, just use go mod
if err := check.ValidGoSum(); err != nil {
cmd := []string{"go", "mod", "init", check.GetGoPath()}
@@ -129,13 +137,10 @@ func makeValidGoSum(check *gitpb.Repo) error {
if err := check.RunStrict([]string{"go", "mod", "tidy"}); err != nil {
log.Info("go mod tidy failed", err)
}
- panic("fucknuts")
}
- 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 errors.New(fmt.Sprintf("could have been %v", err))
+ if check.ParseGoSum() {
+ return nil
}
- check.ParseGoSum()
- return nil
+
+ return fmt.Errorf("could not make a valid go.mod")
}