git reset --hard option

This commit is contained in:
Jeff Carr 2024-12-13 17:13:07 -06:00
parent 2b090019a9
commit 10cf50c39b
5 changed files with 37 additions and 8 deletions

View File

@ -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

View File

@ -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"`

View File

@ -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()

View File

@ -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()
}
*/
}

View File

@ -55,6 +55,11 @@ func main() {
done = true
}
if argv.DoGitReset {
doGitReset()
done = true
}
if argv.DoList {
// print out the repos
doCobol()