diff options
| author | Jeff Carr <[email protected]> | 2024-02-23 07:02:31 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-23 07:02:31 -0600 |
| commit | 8f4ae1a639884f0e03e3d6d9a99cf5528d80cd63 (patch) | |
| tree | 20fbf846f8bb5435c1cd85c2cd8bdc475bf6661e /configfile.go | |
| parent | 2975833e643f7cfa8d62e2c59289735ec113d247 (diff) | |
common cmd line handling routinesv0.20.9
Diffstat (limited to 'configfile.go')
| -rw-r--r-- | configfile.go | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/configfile.go b/configfile.go index a339d70..931f232 100644 --- a/configfile.go +++ b/configfile.go @@ -34,3 +34,87 @@ func parsecfg(f string) []string { lines := strings.Split(out, "\n") return lines } + +func (rl *RepoList) ArgCheckoutUser() bool { + log.Info("running git checkout devel everwhere") + var failed int = 0 + for _, repo := range rl.AllRepos() { + if repo.Status.ReadOnly() { + // log.Info("skipping read-only", repo.Name()) + continue + } + if repo.Status.CheckDirty() { + log.Info("skipping dirty repo", repo.Name()) + continue + } + branch := repo.Status.GetUserBranchName() + if branch == repo.Status.GetCurrentBranchName() { + // already on user branch + continue + } + cmd := []string{"git", "checkout", branch} + log.Info("Running:", cmd, "in", repo.Name()) + err, output := repo.RunCmd(cmd) + if err == nil { + log.Info("git checkout worked", output) + } else { + failed += 1 + log.Info("git checkout failed") + log.Info("Something went wrong. Got err", err) + log.Info("output =", output) + // return false + } + } + log.Info("Ran git checkout in all repos. failure count =", failed) + return true +} + +func (rl *RepoList) ArgGitPull() bool { + log.Info("running git pull everywhere") + cmd := []string{"git", "pull"} + var failed int = 0 + for _, repo := range rl.AllRepos() { + log.Info("Running:", repo.Status.Path(), cmd) + err, output := repo.RunCmd(cmd) + if err == nil { + log.Info(output) + } else { + failed += 1 + log.Info("Something went wrong. Got err", err) + log.Info("output =", output) + return false + } + } + log.Info("Ran git pull in all repos. failure count =", failed) + return true +} + +func (rl *RepoList) ArgCheckoutDevel() bool { + log.Info("running git checkout devel everwhere") + var failed int = 0 + for _, repo := range rl.AllRepos() { + if repo.Status.ReadOnly() { + // log.Info("skipping read-only", repo.Name()) + continue + } + if repo.CheckDirty() { + log.Info("skipping dirty repo", repo.Name()) + continue + } + branch := repo.Status.GetDevelBranchName() + cmd := []string{"git", "checkout", branch} + log.Info("Running:", cmd, "in", repo.Name()) + err, output := repo.RunCmd(cmd) + if err == nil { + log.Info("git checkout worked", output) + } else { + failed += 1 + log.Info("git checkout failed") + log.Info("Something went wrong. Got err", err) + log.Info("output =", output) + // return false + } + } + log.Info("Ran git checkout in all repos. failure count =", failed) + return true +} |
