diff options
| author | Jeff Carr <[email protected]> | 2024-12-18 23:05:31 -0600 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-18 23:05:31 -0600 | 
| commit | 9561e45610f62642402bcc182ecd963f133bd10d (patch) | |
| tree | 360aa0c13ef402eb09d5e9a6475034d132d8ac6a | |
| parent | 163484be1f487de1f3239256953a5c0f6feb86a6 (diff) | |
more cleanupsv0.7.9v0.7.8v0.7.23v0.7.22v0.7.21v0.7.20v0.7.19v0.7.18v0.7.17v0.7.16v0.7.15v0.7.14v0.7.13v0.7.12v0.7.11v0.7.10
| -rw-r--r-- | clone.go | 49 | 
1 files changed, 27 insertions, 22 deletions
@@ -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")  }  | 
