code to double check remote branches are in sync
This commit is contained in:
parent
2471b1ea4c
commit
309fcffc86
15
argv.go
15
argv.go
|
@ -52,12 +52,7 @@ type CommitCmd struct {
|
||||||
type testCmd string
|
type testCmd string
|
||||||
|
|
||||||
type CleanCmd struct {
|
type CleanCmd struct {
|
||||||
Delete *EmptyCmd `arg:"subcommand:delete" help:"rescan repo"`
|
Verify *EmptyCmd `arg:"subcommand:verify" 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"`
|
Repo string `arg:"--repo" help:"which repo to look at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,8 +145,6 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI.
|
||||||
//
|
//
|
||||||
|
|
||||||
func DoAutoComplete(argv []string) {
|
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] {
|
switch argv[0] {
|
||||||
case "checkout":
|
case "checkout":
|
||||||
fmt.Println("devel master user")
|
fmt.Println("devel master user")
|
||||||
|
@ -160,11 +153,11 @@ func DoAutoComplete(argv []string) {
|
||||||
// me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
|
// me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
|
||||||
// me.pp.WriteHelpForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
|
// me.pp.WriteHelpForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
|
||||||
// me.pp.WriteHelpForSubcommand(os.Stderr, "clean")
|
// me.pp.WriteHelpForSubcommand(os.Stderr, "clean")
|
||||||
fmt.Println("--force")
|
fmt.Println("--force verify --repo")
|
||||||
case "commit":
|
case "commit":
|
||||||
fmt.Println("--all")
|
fmt.Println("--all")
|
||||||
case "config":
|
case "config":
|
||||||
fmt.Println("add fix list debug")
|
fmt.Println("add fix list")
|
||||||
case "dirty":
|
case "dirty":
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
case "gui":
|
case "gui":
|
||||||
|
@ -196,7 +189,7 @@ func DoAutoComplete(argv []string) {
|
||||||
default:
|
default:
|
||||||
if argv[0] == ARGNAME {
|
if argv[0] == ARGNAME {
|
||||||
// list the subcommands here
|
// 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)
|
os.Exit(0)
|
||||||
|
|
23
doClean.go
23
doClean.go
|
@ -7,13 +7,36 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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
|
// reverts all repos back to the original master branches
|
||||||
// automatically deletes local devel and user branches
|
// automatically deletes local devel and user branches
|
||||||
func doClean() error {
|
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'
|
// fix this to work, then delete all the other options for "forge clean'
|
||||||
if err := me.forge.DoAllCheckoutMaster(); err != nil {
|
if err := me.forge.DoAllCheckoutMaster(); err != nil {
|
||||||
// badExit(err)
|
// badExit(err)
|
||||||
|
|
12
main.go
12
main.go
|
@ -50,6 +50,7 @@ func main() {
|
||||||
me.pp = arg.MustParse(&argv)
|
me.pp = arg.MustParse(&argv)
|
||||||
|
|
||||||
me.forge = forgepb.Init()
|
me.forge = forgepb.Init()
|
||||||
|
me.forge.ScanGoSrc()
|
||||||
|
|
||||||
// initialize patches
|
// initialize patches
|
||||||
doPatchInit()
|
doPatchInit()
|
||||||
|
@ -93,17 +94,6 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Clean != nil {
|
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 {
|
if err := doClean(); err != nil {
|
||||||
badExit(err)
|
badExit(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue