switch to 'verify devel'
This commit is contained in:
parent
ca92a4f4e4
commit
6e7874faa6
7
argv.go
7
argv.go
|
@ -48,6 +48,13 @@ type CleanCmd struct {
|
||||||
Force *EmptyCmd `arg:"subcommand:force" help:"do destructive stuff"`
|
Force *EmptyCmd `arg:"subcommand:force" help:"do destructive stuff"`
|
||||||
GitReset *EmptyCmd `arg:"subcommand:git-reset" help:"git reset --hard"`
|
GitReset *EmptyCmd `arg:"subcommand:git-reset" help:"git reset --hard"`
|
||||||
User *EmptyCmd `arg:"subcommand:user" help:"clean the user branches"`
|
User *EmptyCmd `arg:"subcommand:user" help:"clean the user branches"`
|
||||||
|
Verify *VerifyCmd `arg:"subcommand:verify" help:"verify branches"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VerifyCmd struct {
|
||||||
|
User *FindCmd `arg:"subcommand:user" help:"verify the user branches"`
|
||||||
|
Devel *FindCmd `arg:"subcommand:devel" help:"verify the devel branches"`
|
||||||
|
Master *FindCmd `arg:"subcommand:master" help:"verify the master branches"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CleanDevelCmd struct {
|
type CleanDevelCmd struct {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
// used for shell auto completion
|
// used for shell auto completion
|
||||||
// var ARGNAME string = "forge" // todo: get this from $0 ?
|
// var ARGNAME string = "forge" // todo: get this from $0 ?
|
||||||
|
|
||||||
func (a *EmptyCmd) deleteMatch() {
|
func deleteMatch() {
|
||||||
// f := forgedb.InitSimple()
|
// f := forgedb.InitSimple()
|
||||||
fmt.Println("go.wit.com/lib/gui/repostatus todo: need to do this")
|
fmt.Println("go.wit.com/lib/gui/repostatus todo: need to do this")
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,13 @@ func (args) doBashAuto() {
|
||||||
// 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("delete devel force examine force git-reset user")
|
fmt.Println("delete devel force examine force git-reset user verify")
|
||||||
case "commit":
|
case "commit":
|
||||||
fmt.Println("--all")
|
fmt.Println("--all")
|
||||||
case "config":
|
case "config":
|
||||||
fmt.Println("add fix list")
|
fmt.Println("add fix list")
|
||||||
case "delete":
|
case "delete":
|
||||||
argv.Clean.Delete.deleteMatch()
|
deleteMatch()
|
||||||
case "dirty":
|
case "dirty":
|
||||||
fmt.Println("--verbose")
|
fmt.Println("--verbose")
|
||||||
case "examine":
|
case "examine":
|
||||||
|
@ -49,9 +49,11 @@ func (args) doBashAuto() {
|
||||||
case "user":
|
case "user":
|
||||||
fmt.Println("--force")
|
fmt.Println("--force")
|
||||||
case "devel":
|
case "devel":
|
||||||
fmt.Println("--force")
|
fmt.Println("--verbose")
|
||||||
case "master":
|
case "master":
|
||||||
fmt.Println("--force")
|
fmt.Println("--force")
|
||||||
|
case "verify":
|
||||||
|
fmt.Println("user devel master")
|
||||||
default:
|
default:
|
||||||
if argv.BashAuto[0] == ARGNAME {
|
if argv.BashAuto[0] == ARGNAME {
|
||||||
// list the subcommands here
|
// list the subcommands here
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func doVerifyDevel() error {
|
||||||
|
me.found = new(gitpb.Repos)
|
||||||
|
all := me.forge.Repos.SortByFullPath()
|
||||||
|
for all.Scan() {
|
||||||
|
repo := all.Next()
|
||||||
|
if repo.IsDirty() {
|
||||||
|
log.Info(repo.GetGoPath(), "is dirty")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.GetDevelBranchName() == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.GetMasterBranchName() != repo.GetCurrentBranchName() {
|
||||||
|
log.Info(repo.GetGoPath(), "is not on master branch")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if devel branch exists in remote repo
|
||||||
|
devel := repo.GetDevelBranchName()
|
||||||
|
if argv.Verbose {
|
||||||
|
log.Printf("Start clean devel branch: %s %s\n", repo.GetGoPath(), devel)
|
||||||
|
}
|
||||||
|
|
||||||
|
if repo.Exists(filepath.Join(".git/refs/remotes/origin", devel)) {
|
||||||
|
// todo: actually use .git/config
|
||||||
|
if err := doCleanDevelRepo(repo); err != nil {
|
||||||
|
log.Info(repo.GetGoPath(), "verify clean failed")
|
||||||
|
}
|
||||||
|
// can not continue
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// devel branch is only local
|
||||||
|
/*
|
||||||
|
devname := repo.GetDevelBranchName()
|
||||||
|
if err := requiresGitPush(repo, devname); err != nil {
|
||||||
|
log.Info(repo.GetGoPath(), "is out of sync with upstream")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
err = fmt.Errorf("examineBranch() branch differs. patch diff len == 0. PROBABLY DELETE BRANCH %s", repo.CurrentTag.Refname)
|
||||||
|
log.Info(err)
|
||||||
|
cmd := repo.ConstructGitDiffLog(repo.CurrentTag.Refname, repo.GetMasterBranchName())
|
||||||
|
if argv.Clean.Examine.Fix == nil {
|
||||||
|
log.Info(repo.GetGoPath(), cmd)
|
||||||
|
} else {
|
||||||
|
if _, err := repo.RunVerbose(cmd); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmd = repo.ConstructGitDiffLog(repo.GetMasterBranchName(), repo.CurrentTag.Refname)
|
||||||
|
if argv.Clean.Examine.Fix == nil {
|
||||||
|
log.Info(repo.GetGoPath(), cmd)
|
||||||
|
} else {
|
||||||
|
if _, err := repo.RunVerbose(cmd); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmd = []string{"git", "branch", "-D", repo.CurrentTag.Refname}
|
||||||
|
log.Info(repo.GetGoPath(), "TRY THIS:", cmd)
|
||||||
|
if argv.Clean.Examine.Fix == nil {
|
||||||
|
log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
|
||||||
|
repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
|
||||||
|
} else {
|
||||||
|
log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
|
||||||
|
if _, err := repo.RunVerbose(cmd); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = fmt.Errorf("examineBranch() branch differs, but not sure how to fix it yet == %d", len(dcount))
|
||||||
|
log.Info(err)
|
||||||
|
return nil
|
||||||
|
*/
|
6
main.go
6
main.go
|
@ -85,12 +85,18 @@ func main() {
|
||||||
}
|
}
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Clean.GitReset != nil {
|
if argv.Clean.GitReset != nil {
|
||||||
findAll() // select all the repos
|
findAll() // select all the repos
|
||||||
doGitReset()
|
doGitReset()
|
||||||
okExit("reset")
|
okExit("reset")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if argv.Clean.Verify != nil {
|
||||||
|
doVerifyDevel()
|
||||||
|
okExit("verify")
|
||||||
|
}
|
||||||
|
|
||||||
if err := doClean(); err != nil {
|
if err := doClean(); err != nil {
|
||||||
badExit(err)
|
badExit(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue