diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 51 |
1 files changed, 21 insertions, 30 deletions
@@ -6,8 +6,6 @@ import ( "path/filepath" "go.wit.com/dev/alexflint/arg" - "go.wit.com/gui" - "go.wit.com/lib/gui/repolist" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" @@ -20,10 +18,10 @@ var BUILDTIME string var pp *arg.Parser var forge *forgepb.Forge -var rv *repolist.RepoList var argvRepo *gitpb.Repo func main() { + log.Info("go-clone version", VERSION, "built on", BUILDTIME) pp = arg.MustParse(&argv) // for very new users or users unfamilar with the command line, this may help them @@ -39,8 +37,6 @@ func main() { // load the ~/.config/forge/ config // this lets you configure repos you have read/write access too forge = forgepb.Init() - // forge.ConfigPrintTable() - os.Setenv("REPO_WORK_PATH", forge.GetGoSrc()) argvRepo = forge.Repos.FindByGoPath(argv.Repo) if argvRepo == nil { @@ -48,21 +44,18 @@ func main() { } else { log.Info("already have", argv.Repo) if argv.Recursive { + clone() recursiveClone() } + autoWork() build() okExit(argv.Repo) } // gui is in testing - myGui := gui.New() + // myGui := gui.New() // myGui.Default() - // find and scan all repos - rv := repolist.Init(forge, myGui) - rv.Enable() - rv.ScanRepositories() - // run 'git pull' if argv --git-pull if argv.Pull { gitPull() @@ -72,11 +65,12 @@ func main() { // remake all the go.sum & go.mod in every repo // todo: make go.sum and go.mod git commit metadata if argv.RedoGoMod { - redoGoModAll() + // redoGoModAll() } // this works sometimes if argv.Recursive { + clone() recursiveClone() autoWork() build() @@ -110,7 +104,7 @@ func okExit(thing string) { func badExit(err error) { log.Info("Total repositories:", forge.Repos.Len()) - log.Info("Finished go-clone with error", err) + log.Info("Finished go-clone with error", err, forge.GetGoSrc()) os.Exit(-1) } @@ -119,21 +113,20 @@ func clone() { if argv.Repo != "" { os.Setenv("REPO_AUTO_CLONE", "true") // pb, _ := forge.NewGoPath(argv.Repo) - pb, err := forge.Clone(argv.Repo) - if err != nil { - log.Info("could not download") - badExit(err) + check := forge.Repos.FindByGoPath(argv.Repo) + if check != nil { + return } - newr, err := rv.AddRepo(pb) + pb, err := forge.Clone(argv.Repo) if err != nil { - log.Info("repolist.AddRepo() failed") + log.Info("clone() could not download err:", err) badExit(err) } // update go.sum and go.mod // todo: only do this if they don't exist? // todo: make these git commit metadata - newr.MakeRedoMod() + pb.RedoGoMod() // double check it actually downloaded fullgitdir := filepath.Join(forge.GetGoSrc(), argv.Repo, ".git") @@ -194,7 +187,7 @@ func recursiveClone() { log.Info("download:", depRepo.GoPath) _, err := forge.Clone(depRepo.GoPath) if err != nil { - log.Info("could not download", depRepo.GoPath) + log.Info("recursiveClone() could not download", depRepo.GoPath) log.Info("err:", err) bad += 1 } else { @@ -206,15 +199,13 @@ func recursiveClone() { log.Info("got", good, "repos", "failed on", bad, "repos") } -func redoGoModAll() { - loop := rv.ReposSortByName() - for loop.Scan() { - repo := loop.Repo() - repo.MakeRedoMod() - } -} - func build() error { + forge.RillRedoGoMod() + repos := forge.Repos.SortByGoPath() + for repos.Scan() { + repo := repos.Next() + log.Info("go.work repo (hopefully):", repo.GoPath, repo.FullPath, repo.RepoType()) + } if argv.Install { if err := forge.Install(argvRepo, nil); err == nil { okExit("install worked") @@ -236,7 +227,7 @@ func autoWork() { log.Info("Sleep 3. original go.work saved as go.work.last (hit ctrl-c to cancel)") log.Sleep(3) shell.PathRun(forge.GetGoSrc(), []string{"mv", "go.work", "go.work.last"}) - rv.MakeGoWork() + forge.MakeGoWork() shell.PathRun(forge.GetGoSrc(), []string{"go", "work", "use"}) log.Info("") log.Info("original go.work file saved as go.work.last") |
