git reset --hard option
This commit is contained in:
parent
2b090019a9
commit
10cf50c39b
5
Makefile
5
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
|
||||
|
|
1
argv.go
1
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"`
|
||||
|
|
19
doCommon.go
19
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()
|
||||
|
|
15
findRepos.go
15
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()
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue