diff --git a/Makefile b/Makefile index bf158ce..aeb0890 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/argv.go b/argv.go index 5526312..c35706b 100644 --- a/argv.go +++ b/argv.go @@ -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() + } + */ } diff --git a/main.go b/main.go index c6d2683..9e96f10 100644 --- a/main.go +++ b/main.go @@ -55,6 +55,11 @@ func main() { done = true } + if argv.DoGitReset { + doGitReset() + done = true + } + if argv.DoList { // print out the repos doCobol()