add --ignore for edge cases to see what happens

This commit is contained in:
Jeff Carr 2024-12-15 15:51:27 -06:00
parent bab2506d34
commit 882c448b85
2 changed files with 27 additions and 3 deletions

View File

@ -16,6 +16,7 @@ type args struct {
Pull bool `arg:"--git-pull" default:"false" help:"run 'git pull'"` Pull bool `arg:"--git-pull" default:"false" help:"run 'git pull'"`
Build bool `arg:"--build" default:"true" help:"try to build it after clone"` Build bool `arg:"--build" default:"true" help:"try to build it after clone"`
Install bool `arg:"--install" default:"false" help:"try to install it after clone"` Install bool `arg:"--install" default:"false" help:"try to install it after clone"`
Ignore bool `arg:"--ignore" default:"false" help:"ignore weird clone errors from non-standard repos"`
// Fetch bool `arg:"--git-fetch" default:"false" help:"run 'git fetch' on all your repos"` // Fetch bool `arg:"--git-fetch" default:"false" help:"run 'git fetch' on all your repos"`
} }

View File

@ -2,6 +2,7 @@ package main
import ( import (
"errors" "errors"
"fmt"
"os" "os"
"path/filepath" "path/filepath"
@ -99,15 +100,27 @@ func recursiveClone(check *gitpb.Repo) error {
} }
log.Info("got", good, "repos", "failed on", bad, "repos") log.Info("got", good, "repos", "failed on", bad, "repos")
if bad != 0 { if bad != 0 {
log.Info("clone() ERROR len(badmap)", len(badmap))
for gopath, err := range badmap { for gopath, err := range badmap {
log.Info("clone() error", gopath, err) log.Info("clone() ERROR", gopath, err)
}
if !argv.Ignore {
return errors.New("clone failed on some repos")
} }
return errors.New("clone failed on some repos")
} }
return nil return nil
} }
func makeValidGoSum(check *gitpb.Repo) error { func makeValidGoSum(check *gitpb.Repo) error {
if check.Exists("go.mod") {
if err := check.SetPrimitive(); err != nil {
return err
}
}
if check.GoPrimitive {
log.Info(check.GoPath, "is a golang primitive! no need to parse go.sum because there is not one!")
return nil
}
// first try to generate go.mod & go.sum with go-mod-clean // first try to generate go.mod & go.sum with go-mod-clean
if err := check.ValidGoSum(); err != nil { if err := check.ValidGoSum(); err != nil {
log.Info("try running go-mod-clean") log.Info("try running go-mod-clean")
@ -126,14 +139,24 @@ func makeValidGoSum(check *gitpb.Repo) error {
if err := check.RunStrict(cmd); err != nil { if err := check.RunStrict(cmd); err != nil {
log.Info("go mod init failed", err) log.Info("go mod init failed", err)
} }
if check.Exists("go.mod") {
if err := check.SetPrimitive(); err != nil {
return err
}
}
if check.GoPrimitive {
log.Info(check.GoPath, "is a golang primitive! no need to parse go.sum because there is not one!")
return nil
}
if err := check.RunStrict([]string{"go", "mod", "tidy"}); err != nil { if err := check.RunStrict([]string{"go", "mod", "tidy"}); err != nil {
log.Info("go mod tidy failed", err) log.Info("go mod tidy failed", err)
} }
panic("fucknuts")
} }
if err := check.ValidGoSum(); err != nil { if err := check.ValidGoSum(); err != nil {
// have to give up. can't recursive clone without go.mod file // have to give up. can't recursive clone without go.mod file
log.Info("could not generate valid go.sum file") log.Info("could not generate valid go.sum file")
return err return errors.New(fmt.Sprintf("could have been %v", err))
} }
check.ParseGoSum() check.ParseGoSum()
return nil return nil