diff options
| author | Jeff Carr <[email protected]> | 2024-11-08 06:45:25 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-08 06:45:25 -0600 |
| commit | 9878b8fe6cce13c48bdaebdfe0dc8266268b7da9 (patch) | |
| tree | 597fc6596f403f2dc93cf2d9b832cc886e039391 /main.go | |
| parent | 4cee81ca2dfa576671c2332afe4daa0202314bdb (diff) | |
use go-cmd/cmdv0.5.5
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 58 |
1 files changed, 47 insertions, 11 deletions
@@ -22,11 +22,6 @@ var rv *repolist.RepoList func main() { pp := arg.MustParse(&argv) - if argv.Repo == "" { - pp.WriteHelp(os.Stdout) - os.Exit(0) - } - // for very new users or users unfamilar with the command line, this may help them if argv.Repo == "version" || argv.Repo == "help" || argv.Repo == "?" { pp.WriteHelp(os.Stdout) @@ -47,6 +42,38 @@ func main() { b := gui.RawBox() rv = repolist.AutotypistView(b) + log.Info("got here") + if argv.Pull { + count := scanForRepos(wdir) + log.Info("Total repositories:", count) + log.Info("Going to run git pull in each one") + log.Sleep(1) + pull := []string{"git", "pull"} + loop := rv.ReposSortByName() + var trycount, errcount int + for loop.Scan() { + repo := loop.Repo() + if argv.DryRun { + log.Info("git pull --dry-run", repo.Status.Path()) + } else { + trycount += 1 + log.Info("actually run: git pull:", repo.Status.Path()) + if err := shell.PwdRun(repo.Status.Path(), pull); err != nil { + log.Info("git pull error:", err) + errcount += 1 + } + } + } + log.Info("Total repositories:", count, "Total attempted:", trycount, "Errors:", errcount) + os.Exit(0) + } + + // if the user didn't provide a repo, stop here + if argv.Repo == "" { + pp.WriteHelp(os.Stdout) + os.Exit(0) + } + os.Setenv("REPO_AUTO_CLONE", "true") newr, err := rv.NewRepo(argv.Repo) if err != nil { @@ -98,12 +125,6 @@ func main() { rv.MakeGoWork() shell.RunPath(wdir, []string{"go", "work", "use"}) } - - /* - for _, repo := range rv.AllRepos() { - log.Info("found repo", repo.GoPath(), repo.Status.Path()) - } - */ } // look for or make a go.work file @@ -174,3 +195,18 @@ func digup(path string) (string, error) { return "", fmt.Errorf("no go.work file found") } + +func scanForRepos(wdir string) int { + var count int + log.Info("scanning for repo in:", filepath.Join(wdir, argv.Repo)) + + // rv.NewRepo("go.wit.com/apps/helloworld") + for _, path := range repostatus.ScanGitDirectories(wdir) { + count += 1 + gopath := strings.TrimPrefix(path, wdir) + gopath = strings.Trim(gopath, "/") + // log.Info("Also should add:", gopath) + rv.NewRepo(gopath) + } + return count +} |
