code to double check remote branches are in sync
This commit is contained in:
parent
2471b1ea4c
commit
309fcffc86
17
argv.go
17
argv.go
|
@ -52,13 +52,8 @@ type CommitCmd struct {
|
|||
type testCmd string
|
||||
|
||||
type CleanCmd struct {
|
||||
Delete *EmptyCmd `arg:"subcommand:delete" help:"rescan repo"`
|
||||
Devel *CleanDevelCmd `arg:"subcommand:devel" help:"clean and verify the devel branches"`
|
||||
Force *EmptyCmd `arg:"subcommand:force" help:"do destructive stuff"`
|
||||
GitReset *EmptyCmd `arg:"subcommand:git-reset" help:"git reset --hard"`
|
||||
Pub *EmptyCmd `arg:"subcommand:pub" help:"clean target version numbers"`
|
||||
User *EmptyCmd `arg:"subcommand:user" help:"clean the user branches"`
|
||||
Repo string `arg:"--repo" help:"which repo to look at"`
|
||||
Verify *EmptyCmd `arg:"subcommand:verify" help:"rescan repo"`
|
||||
Repo string `arg:"--repo" help:"which repo to look at"`
|
||||
}
|
||||
|
||||
type CleanDevelCmd struct {
|
||||
|
@ -150,8 +145,6 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI.
|
|||
//
|
||||
|
||||
func DoAutoComplete(argv []string) {
|
||||
// fmt.Fprintln(os.Stderr, "") // these are for debugging
|
||||
// fmt.Fprintln(os.Stderr, "in autocomplete:", argv) // these are for debugging
|
||||
switch argv[0] {
|
||||
case "checkout":
|
||||
fmt.Println("devel master user")
|
||||
|
@ -160,11 +153,11 @@ func DoAutoComplete(argv []string) {
|
|||
// me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
|
||||
// me.pp.WriteHelpForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
|
||||
// me.pp.WriteHelpForSubcommand(os.Stderr, "clean")
|
||||
fmt.Println("--force")
|
||||
fmt.Println("--force verify --repo")
|
||||
case "commit":
|
||||
fmt.Println("--all")
|
||||
case "config":
|
||||
fmt.Println("add fix list debug")
|
||||
fmt.Println("add fix list")
|
||||
case "dirty":
|
||||
fmt.Println("")
|
||||
case "gui":
|
||||
|
@ -196,7 +189,7 @@ func DoAutoComplete(argv []string) {
|
|||
default:
|
||||
if argv[0] == ARGNAME {
|
||||
// list the subcommands here
|
||||
fmt.Println("help list checkout clean commit dirty debug fetch gui normal merge patch pull")
|
||||
fmt.Println("help list checkout clean commit dirty fetch gui normal merge patch pull")
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
|
|
23
doClean.go
23
doClean.go
|
@ -7,13 +7,36 @@ import (
|
|||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func checkRemoteBranches(repo *gitpb.Repo) error {
|
||||
if repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) {
|
||||
repo.Reload()
|
||||
me.forge.SetConfigSave(true)
|
||||
return log.Errorf("devel is bad")
|
||||
}
|
||||
if repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) {
|
||||
repo.Reload()
|
||||
me.forge.SetConfigSave(true)
|
||||
return log.Errorf("master is bad")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// reverts all repos back to the original master branches
|
||||
// automatically deletes local devel and user branches
|
||||
func doClean() error {
|
||||
me.forge.Config.Mode = forgepb.ForgeMode_CLEAN
|
||||
|
||||
if argv.Clean.Verify != nil {
|
||||
stats := me.forge.RillRepos(checkRemoteBranches)
|
||||
_ = stats
|
||||
return nil
|
||||
}
|
||||
|
||||
// fix this to work, then delete all the other options for "forge clean'
|
||||
if err := me.forge.DoAllCheckoutMaster(); err != nil {
|
||||
// badExit(err)
|
||||
|
|
12
main.go
12
main.go
|
@ -50,6 +50,7 @@ func main() {
|
|||
me.pp = arg.MustParse(&argv)
|
||||
|
||||
me.forge = forgepb.Init()
|
||||
me.forge.ScanGoSrc()
|
||||
|
||||
// initialize patches
|
||||
doPatchInit()
|
||||
|
@ -93,17 +94,6 @@ func main() {
|
|||
}
|
||||
|
||||
if argv.Clean != nil {
|
||||
me.forge.Config.Mode = forgepb.ForgeMode_CLEAN
|
||||
if argv.Clean.Repo != "" {
|
||||
log.Info("only looking at repo:", argv.Clean.Repo)
|
||||
okExit("")
|
||||
}
|
||||
|
||||
if argv.Clean.GitReset != nil {
|
||||
doGitReset()
|
||||
okExit("reset")
|
||||
}
|
||||
|
||||
if err := doClean(); err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue