diff --git a/Makefile b/Makefile index 007eee0..484f025 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,12 @@ redomod: GO111MODULE= go mod init GO111MODULE= go mod tidy +redomod-all: + ./forge --RedoGoMod + +redomod-erase: + ./forge --RedoGoMod --erase + list: build reset ./forge --list diff --git a/argv.go b/argv.go index 9f79d48..0237182 100644 --- a/argv.go +++ b/argv.go @@ -21,6 +21,8 @@ type args struct { Real bool `arg:"--fix" help:"fix config, save config & exit"` Repomap string `arg:"--repomap" help:"parse a repomap from gowebd"` Clone bool `arg:"--clone" help:"go-clone things you are missing"` + Force bool `arg:"--force" help:"force redo go-clone"` + Erase bool `arg:"--erase" help:"erase"` } func (args) Version() string { diff --git a/list.go b/list.go index 4e4cca4..da733ad 100644 --- a/list.go +++ b/list.go @@ -51,13 +51,20 @@ func verifyPrint(repo *gitpb.Repo) { os.Exit(0) } } - if me.forge.IsReadOnly(repo.GoPath) && !argv.ReadOnly { + if me.forge.IsReadOnly(repo) && !argv.ReadOnly { + if repo.ReadOnly { + return + } + log.Info("readonly flag on repo is wrong", repo.GoPath) return } start := fmt.Sprintf("%-40s %-8s %-20s %-20s %-20s", s["gopath"], s["rtype"], s["cver"], s["mver"], s["cver"]) if s["url"] != "" { end += "(" + s["url"] + ") " } + if repo.ReadOnly { + end += "(readonly) " + } // end += fmt.Sprintf("(%s,%s,%s,%s) ", s["mname"], s["dname"], s["uname"], s["cname"]) log.Info(start, end) } @@ -76,7 +83,7 @@ func verify(repo *gitpb.Repo, s map[string]string) bool { return false } // only verify the master branch name with read-only repos - if me.forge.IsReadOnly(repo.GoPath) { + if me.forge.IsReadOnly(repo) { s["mver"] = repo.GetMasterVersion() return true } diff --git a/main.go b/main.go index 7b0bef8..4b9b7c3 100644 --- a/main.go +++ b/main.go @@ -30,9 +30,10 @@ func main() { list() scan() repomap() - os.Exit(0) if argv.RedoGoMod { + me.forge.RillRedoGoMod() + os.Exit(0) repos := me.forge.Repos.SortByGoPath() for repos.Scan() { repo := repos.Next() @@ -40,14 +41,15 @@ func main() { log.Printf("%10s %-50s", "old?", repo.GetGoPath()) continue } - if me.forge.IsReadOnly(repo.GetGoPath()) { - log.Printf("%10s %-50s", "readonly", repo.GetGoPath()) - continue + log.Printf("running on: %-50s", repo.GetGoPath()) + if argv.Erase { + repo.EraseGoMod() + } else { + repo.RedoGoMod() } - repo.RedoGoMod() } - os.Exit(0) } + os.Exit(0) me.myGui = gui.New() me.myGui.Default() diff --git a/repomap.go b/repomap.go index 877681f..8b23368 100644 --- a/repomap.go +++ b/repomap.go @@ -30,10 +30,13 @@ func repomap() { comment = strings.Join(parts[2:], " ") } repo := me.forge.Repos.FindByGoPath(gopath) + if argv.Force && argv.Clone { + cmd := []string{"go-clone", "--recursive", gopath} + shell.RunRealtime(cmd) + continue + } if repo == nil { if argv.Clone { - cmd := []string{"go-clone", "--recursive", gopath} - shell.RunRealtime(cmd) // me.forge.Clone(gopath) } else { log.Info(gopath, "need to clone")