add 'fix' flag
This commit is contained in:
parent
3bdf0143be
commit
f4838d7500
1
argv.go
1
argv.go
|
@ -67,6 +67,7 @@ type RepoCmd struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type NormalCmd struct {
|
type NormalCmd struct {
|
||||||
|
Fix *EmptyCmd `arg:"subcommand:fix" help:"try to fix problems"`
|
||||||
On *EmptyCmd `arg:"subcommand:on" help:"turn normal mode on"`
|
On *EmptyCmd `arg:"subcommand:on" help:"turn normal mode on"`
|
||||||
Off *EmptyCmd `arg:"subcommand:off" help:"turn normal mode off"`
|
Off *EmptyCmd `arg:"subcommand:off" help:"turn normal mode off"`
|
||||||
}
|
}
|
||||||
|
|
10
doClean.go
10
doClean.go
|
@ -94,18 +94,19 @@ func doClean() error {
|
||||||
// when publishing, clean out the details of that if it's still there
|
// when publishing, clean out the details of that if it's still there
|
||||||
if repo.GetTargetVersion() != "" {
|
if repo.GetTargetVersion() != "" {
|
||||||
repo.SetTargetVersion("")
|
repo.SetTargetVersion("")
|
||||||
configSave = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to delete user
|
// try to delete user
|
||||||
if err := doRepoCleanUser(repo); err != nil {
|
if err := doRepoCleanUser(repo); err != nil {
|
||||||
if err == ErrorBranchUnique {
|
if err == ErrorBranchUnique {
|
||||||
|
if argv.Clean.Fix != nil {
|
||||||
bname := repo.GetUserBranchName()
|
bname := repo.GetUserBranchName()
|
||||||
s := fmt.Sprintf("delete this odd user %bname branch %s?", bname, repo.FullPath)
|
s := fmt.Sprintf("delete this odd user (%s) branch %s?", bname, repo.FullPath)
|
||||||
if fhelp.QuestionUser(s) {
|
if fhelp.QuestionUser(s) {
|
||||||
repo.RunVerbose([]string{"git", "branch", "-D", bname})
|
repo.RunVerbose([]string{"git", "branch", "-D", bname})
|
||||||
// repo.RunVerbose([]string{"git", "checkout", bname})
|
// repo.RunVerbose([]string{"git", "checkout", bname})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Info(repo.GetGoPath(), err)
|
log.Info(repo.GetGoPath(), err)
|
||||||
}
|
}
|
||||||
|
@ -187,13 +188,14 @@ func doRepoCleanDevel(repo *gitpb.Repo) error {
|
||||||
}
|
}
|
||||||
if err := justDeleteTheDevelBranchAlready(repo); err != nil {
|
if err := justDeleteTheDevelBranchAlready(repo); err != nil {
|
||||||
log.Info("justDeleteTheDevel() err", repo.GetGoPath(), err)
|
log.Info("justDeleteTheDevel() err", repo.GetGoPath(), err)
|
||||||
|
if argv.Clean.Fix != nil {
|
||||||
bname := repo.GetDevelBranchName()
|
bname := repo.GetDevelBranchName()
|
||||||
s := fmt.Sprintf("delete this odd devel %bname branch %s?", bname, repo.FullPath)
|
s := fmt.Sprintf("delete this odd devel (%s) branch %s?", bname, repo.FullPath)
|
||||||
if fhelp.QuestionUser(s) {
|
if fhelp.QuestionUser(s) {
|
||||||
repo.RunVerbose([]string{"git", "branch", "-D", bname})
|
repo.RunVerbose([]string{"git", "branch", "-D", bname})
|
||||||
// repo.RunVerbose([]string{"git", "checkout", bname})
|
// repo.RunVerbose([]string{"git", "checkout", bname})
|
||||||
}
|
}
|
||||||
configSave = true
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
21
doNormal.go
21
doNormal.go
|
@ -15,7 +15,6 @@ import (
|
||||||
"go.wit.com/lib/config"
|
"go.wit.com/lib/config"
|
||||||
"go.wit.com/lib/fhelp"
|
"go.wit.com/lib/fhelp"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -35,7 +34,7 @@ func doNormal() bool {
|
||||||
}
|
}
|
||||||
repo := me.forge.Repos.FindByFullPath(path)
|
repo := me.forge.Repos.FindByFullPath(path)
|
||||||
if stat.Err == ErrorLocalDevelBranch {
|
if stat.Err == ErrorLocalDevelBranch {
|
||||||
if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL {
|
if argv.Normal.Fix != nil {
|
||||||
bname := repo.GetDevelBranchName()
|
bname := repo.GetDevelBranchName()
|
||||||
s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath)
|
s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath)
|
||||||
if fhelp.QuestionUser(s) {
|
if fhelp.QuestionUser(s) {
|
||||||
|
@ -46,7 +45,7 @@ func doNormal() bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if stat.Err == ErrorLocalMasterBranch {
|
if stat.Err == ErrorLocalMasterBranch {
|
||||||
if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL {
|
if argv.Normal.Fix != nil {
|
||||||
bname := repo.GetMasterBranchName()
|
bname := repo.GetMasterBranchName()
|
||||||
s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath)
|
s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath)
|
||||||
if fhelp.QuestionUser(s) {
|
if fhelp.QuestionUser(s) {
|
||||||
|
@ -125,25 +124,9 @@ func checkNormalRepoState(repo *gitpb.Repo) error {
|
||||||
|
|
||||||
if !repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) {
|
if !repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) {
|
||||||
return ErrorLocalDevelBranch
|
return ErrorLocalDevelBranch
|
||||||
/*
|
|
||||||
bname := repo.GetDevelBranchName()
|
|
||||||
s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath)
|
|
||||||
if fhelp.QuestionUser(s) {
|
|
||||||
repo.RunVerbose([]string{"git", "branch", "-D", bname})
|
|
||||||
repo.RunVerbose([]string{"git", "checkout", bname})
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
if !repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) {
|
if !repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) {
|
||||||
return ErrorLocalMasterBranch
|
return ErrorLocalMasterBranch
|
||||||
/*
|
|
||||||
bname := repo.GetMasterBranchName()
|
|
||||||
s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath)
|
|
||||||
if fhelp.QuestionUser(s) {
|
|
||||||
repo.RunVerbose([]string{"git", "branch", "-D", bname})
|
|
||||||
repo.RunVerbose([]string{"git", "checkout", bname})
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
|
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
|
||||||
|
|
Loading…
Reference in New Issue