diff options
| author | Jeff Carr <[email protected]> | 2024-12-13 17:13:07 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-13 17:13:07 -0600 |
| commit | 10cf50c39b19a0c023869bf2fbf27a3ec1996856 (patch) | |
| tree | aef6a224d937d0c922c119253045cd93237b6be0 | |
| parent | 2b090019a9149bf89f883c46786476ef8a827069 (diff) | |
git reset --hard optionv0.22.13
| -rw-r--r-- | Makefile | 5 | ||||
| -rw-r--r-- | argv.go | 1 | ||||
| -rw-r--r-- | doCommon.go | 19 | ||||
| -rw-r--r-- | findRepos.go | 15 | ||||
| -rw-r--r-- | main.go | 5 |
5 files changed, 37 insertions, 8 deletions
@@ -35,7 +35,10 @@ private: install forge --find-private fix: install - forge --fix + forge --fix --find-all + +fix-git-reset: install + forge --do-git-reset --find-all readonly: install forge --do-list --find-readonly @@ -18,6 +18,7 @@ type args struct { DoClone bool `arg:"--do-clone" help:"go-clone things you are missing"` DoForce bool `arg:"--do-force" help:"force redo go-clone"` DoGitPull bool `arg:"--do-git-pull" help:"run 'git pull' on all your repos"` + DoGitReset bool `arg:"--do-git-reset" help:"run 'git reset --hard' on all read-only repos"` DoBuild bool `arg:"--do-build" default:"true" help:"also try to build it"` DoInstall bool `arg:"--do-install" help:"try to install every binary package"` DoRedoGoMod bool `arg:"--do-RedoGoMod" help:"remake all the go.sum and go.mod files"` diff --git a/doCommon.go b/doCommon.go index 296f1cb..3e94055 100644 --- a/doCommon.go +++ b/doCommon.go @@ -33,6 +33,25 @@ func doGitPull() { } } +func doGitReset() { + if !argv.DoGitReset { + return + } + all := me.found.SortByGoPath() + for all.Scan() { + repo := all.Next() + if me.forge.Config.IsReadOnly(repo.GoPath) { + // log.Info("is readonly", repo.GoPath) + if repo.CheckDirty() { + log.Info("is readonly and dirty", repo.GoPath) + cmd := []string{"git", "reset", "--hard"} + repo.RunRealtime(cmd) + } + } else { + // log.Info("is not readonly", repo.GoPath) + } + } +} func doFix() { all := me.found.SortByGoPath() diff --git a/findRepos.go b/findRepos.go index 3562802..453f904 100644 --- a/findRepos.go +++ b/findRepos.go @@ -69,23 +69,24 @@ func findFavorites() { } func findAll() { - var configsave bool all := me.forge.Repos.SortByGoPath() for all.Scan() { repo := all.Next() + me.found.AppendUniqueGoPath(repo) if me.forge.Config.IsReadOnly(repo.GoPath) && !argv.FindReadOnly { if repo.ReadOnly { continue } log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GoPath) repo.ReadOnly = true - configsave = true + configSave = true continue } - me.found.AppendUniqueGoPath(repo) - } - if configsave { - log.Info("should ConfigSave here") - me.forge.Repos.ConfigSave() } + /* + if configsave { + log.Info("should ConfigSave here") + me.forge.Repos.ConfigSave() + } + */ } @@ -55,6 +55,11 @@ func main() { done = true } + if argv.DoGitReset { + doGitReset() + done = true + } + if argv.DoList { // print out the repos doCobol() |
