more cleanups
This commit is contained in:
parent
163484be1f
commit
9561e45610
49
clone.go
49
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())
|
||||||
log.Info("STARTING RECURSIVE CLONE", check.GetGoPath())
|
log.Info("STARTING RECURSIVE CLONE", check.GetGoPath())
|
||||||
if check.GoInfo.GoPrimitive {
|
// if just cloned, parse the go.sum file for deps
|
||||||
log.Info("repo is a primitive", check.GetGoPath())
|
if check.ParseGoSum() {
|
||||||
|
} else {
|
||||||
|
makeValidGoSum(check)
|
||||||
|
}
|
||||||
|
if check.GetGoPrimitive() {
|
||||||
// go primitive repos are "pure"
|
// go primitive repos are "pure"
|
||||||
|
log.Info("repo is primitive", check.GetGoPath())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// if just cloned, parse the go.sum file for deps
|
|
||||||
check.ParseGoSum()
|
|
||||||
|
|
||||||
if check.GoDeps == nil {
|
if check.GoDeps == nil {
|
||||||
log.Info("repo godeps == nil", check.GetGoPath())
|
log.Info("repo godeps == nil", check.GetGoPath())
|
||||||
return errors.New("go.sum is missing?")
|
return errors.New("go.sum is missing?")
|
||||||
|
@ -108,17 +110,23 @@ func makeValidGoSum(check *gitpb.Repo) error {
|
||||||
// attempt to grab the notes
|
// attempt to grab the notes
|
||||||
check.Run([]string{"git", "fetch", "origin", "refs/notes/*:refs/notes/*"})
|
check.Run([]string{"git", "fetch", "origin", "refs/notes/*:refs/notes/*"})
|
||||||
|
|
||||||
// first try to generate go.mod & go.sum with go-mod-clean
|
if check.ParseGoSum() {
|
||||||
if err := check.ValidGoSum(); err != nil {
|
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("")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 this fails, just use go mod
|
||||||
if err := check.ValidGoSum(); err != nil {
|
if err := check.ValidGoSum(); err != nil {
|
||||||
cmd := []string{"go", "mod", "init", check.GetGoPath()}
|
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 {
|
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 check.ParseGoSum() {
|
||||||
// have to give up. can't recursive clone without go.mod file
|
return nil
|
||||||
log.Info("could not generate valid go.sum file")
|
|
||||||
return errors.New(fmt.Sprintf("could have been %v", err))
|
|
||||||
}
|
}
|
||||||
check.ParseGoSum()
|
|
||||||
return nil
|
return fmt.Errorf("could not make a valid go.mod")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue