summaryrefslogtreecommitdiff
path: root/doSmart.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-07 09:51:18 -0600
committerJeff Carr <[email protected]>2025-02-07 09:51:18 -0600
commit7265c0d6a1bdd62142ac6f75a6a348587260f8ec (patch)
treedae12c38a836d6692a042374d3f9199810c3a61a /doSmart.go
parent9da0b6973450c082e1771d523c8b2becabf25862 (diff)
bash autocomplete kinda works, kinda doesn't for some reasonv0.0.41
Diffstat (limited to 'doSmart.go')
-rw-r--r--doSmart.go46
1 files changed, 16 insertions, 30 deletions
diff --git a/doSmart.go b/doSmart.go
index 1f32138..f6dec96 100644
--- a/doSmart.go
+++ b/doSmart.go
@@ -8,9 +8,6 @@ import (
// this will make go.mod and go.sum files, but you have to
// have the files in .gitignore for now
func doSmart(repo *gitpb.Repo) error {
- // erase the go.mod and go.sum files
- eraseGoMod(repo)
-
// if the repo has go.mod in the repo...
if err := repo.RepoIgnoresGoMod(); err != nil {
if repo.ParseGoSum() {
@@ -19,51 +16,40 @@ func doSmart(repo *gitpb.Repo) error {
log.Info("go-mod-clean can not run on this repo", repo.GetGoPath())
log.Info("go.mod and go.sum must be git metadata to continue")
// return nil
+ if repo.Exists("go.sum") {
+ return nil
+ }
}
- if repo.Exists("go.mod") {
- return nil
- }
+ // erase the go.mod and go.sum files
+ eraseGoMod(repo)
// try to restore from the git metadata
cname := repo.GetCurrentBranchName()
if err := repo.AutogenRestore(cname); err == nil {
log.Info(repo.GetGoPath(), "files were restored ok from git metadata (notes)")
- }
- if repo.Exists("go.mod") {
- return nil
- }
-
- // attempt to restore from ~/go/pkg/mod/
- if err := restoreFromGoPkg(repo); err == nil {
- log.Info(repo.GetGoPath(), "files were restored ok ~/go/mod/")
- }
- if repo.Exists("go.mod") {
- return nil
+ if repo.Exists("go.mod") {
+ return nil
+ }
+ // autogen restore didn't find go.mod
}
// actually will re-create go.sum and go.mod now
if err := redoGoMod(repo); err != nil {
- log.Info(repo.GetGoPath(), "the files were restored with redoGoMod()")
+ return err
}
+ log.Info(repo.GetGoPath(), "the files were restored with redoGoMod()")
if repo.Exists("go.mod") {
return nil
}
// the first time, it'll attempt to fix some stuff
- cleanGoDepsCheckOk(repo)
- // try to trim junk
- if err := trimGoSum(repo); err != nil {
+ if err := cleanGoDepsCheckOk(repo); err != nil {
+ return err
}
- if repo.Exists("go.mod") {
- return nil
- }
- repo.ParseGoSum()
- if repo.Exists("go.mod") {
- return nil
+ // trim junk that might have been added by cleanGoDepsCheckOk()
+ if err := trimGoSum(repo); err != nil {
+ return err
}
- // last chance. just run go mod init
- repo.RunVerbose([]string{"go", "mod", "init"})
-
return nil
}