start an 'examine' argv
This commit is contained in:
parent
af84727178
commit
9acbb24284
3
Makefile
3
Makefile
|
@ -2,7 +2,8 @@ VERSION = $(shell git describe --tags)
|
||||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||||
|
|
||||||
info: install
|
info: install
|
||||||
forge dirty
|
# forge dirty
|
||||||
|
forge examine
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@GO111MODULE=off go vet
|
@GO111MODULE=off go vet
|
||||||
|
|
3
argv.go
3
argv.go
|
@ -21,7 +21,8 @@ type args struct {
|
||||||
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
|
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
|
||||||
Rescan *EmptyCmd `arg:"subcommand:rescan" help:"recreate the git protobuf repos.pb file"`
|
Rescan *EmptyCmd `arg:"subcommand:rescan" help:"recreate the git protobuf repos.pb file"`
|
||||||
Delete *EmptyCmd `arg:"subcommand:delete" help:"untrack a repo"`
|
Delete *EmptyCmd `arg:"subcommand:delete" help:"untrack a repo"`
|
||||||
Commit *EmptyCmd `arg:"subcommand:commit" help:"smart 'git commit'"`
|
Commit *EmptyCmd `arg:"subcommand:commit" help:"smart 'git commit' (errors out if on wrong branch)"`
|
||||||
|
Examine *EmptyCmd `arg:"subcommand:examine" help:"examine branches"`
|
||||||
URL string `arg:"--connect" help:"gowebd url"`
|
URL string `arg:"--connect" help:"gowebd url"`
|
||||||
All bool `arg:"--all" help:"git commit --all"`
|
All bool `arg:"--all" help:"git commit --all"`
|
||||||
Show string `arg:"--show" help:"show a repo"`
|
Show string `arg:"--show" help:"show a repo"`
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (args) doBashAuto() {
|
||||||
default:
|
default:
|
||||||
if argv.BashAuto[0] == ARGNAME {
|
if argv.BashAuto[0] == ARGNAME {
|
||||||
// list the subcommands here
|
// list the subcommands here
|
||||||
fmt.Println("--bash checkout commit config dirty delete hard-reset list patch pull rescan")
|
fmt.Println("--bash checkout commit config dirty delete examine hard-reset list patch pull rescan")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
|
@ -1,66 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"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 doGitPull() {
|
|
||||||
allerr := me.found.RillGitPull(40, 5)
|
|
||||||
|
|
||||||
all := me.found.SortByFullPath()
|
|
||||||
for all.Scan() {
|
|
||||||
repo := all.Next()
|
|
||||||
result := allerr[repo]
|
|
||||||
if result.Error == gitpb.ErrorGitPullOnDirty {
|
|
||||||
log.Info("skip git pull. repo is dirty", repo.GetGoPath())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if result.Error == gitpb.ErrorGitPullOnLocal {
|
|
||||||
log.Info("skip git pull. local branch ", repo.GetGoPath())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if result.Exit == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Info("git pull error:", repo.GetGoPath(), result.Error)
|
|
||||||
log.Info("git pull error:", repo.GetGoPath(), result.Stdout)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func doCheckDirtyAndConfigSave() {
|
|
||||||
var count int
|
|
||||||
now := time.Now()
|
|
||||||
// log.Info("before findAll()")
|
|
||||||
all := me.found.SortByFullPath()
|
|
||||||
for all.Scan() {
|
|
||||||
repo := all.Next()
|
|
||||||
// log.Info("before isDirty()")
|
|
||||||
dirty := repo.IsDirty()
|
|
||||||
if repo.CheckDirty() {
|
|
||||||
count += 1
|
|
||||||
if me.found.AppendByGoPath(repo) {
|
|
||||||
log.Info("doCheckDirtyAndConfigSave() repo already existed", repo.GetGoPath())
|
|
||||||
}
|
|
||||||
if !dirty {
|
|
||||||
configSave = true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if dirty {
|
|
||||||
configSave = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.Printf("dirty check (%d repos) took:%s\n", count, shell.FormatDuration(time.Since(now)))
|
|
||||||
me.forge.SetConfigSave(configSave)
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsEverythingOnDevel() bool {
|
func IsEverythingOnDevel() bool {
|
||||||
me.found = new(gitpb.Repos)
|
me.found = new(gitpb.Repos)
|
||||||
all := me.forge.Repos.SortByFullPath()
|
all := me.forge.Repos.SortByFullPath()
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func doDirty() {
|
||||||
|
findAll() // select all the repos
|
||||||
|
doCheckDirtyAndConfigSave()
|
||||||
|
me.found = new(gitpb.Repos)
|
||||||
|
findDirty()
|
||||||
|
me.forge.PrintHumanTableDirty(me.found)
|
||||||
|
}
|
||||||
|
|
||||||
|
func doCheckDirtyAndConfigSave() {
|
||||||
|
var count int
|
||||||
|
now := time.Now()
|
||||||
|
// log.Info("before findAll()")
|
||||||
|
all := me.found.SortByFullPath()
|
||||||
|
for all.Scan() {
|
||||||
|
repo := all.Next()
|
||||||
|
// log.Info("before isDirty()")
|
||||||
|
dirty := repo.IsDirty()
|
||||||
|
if repo.CheckDirty() {
|
||||||
|
count += 1
|
||||||
|
if me.found.AppendByGoPath(repo) {
|
||||||
|
log.Info("doCheckDirtyAndConfigSave() repo already existed", repo.GetGoPath())
|
||||||
|
}
|
||||||
|
if !dirty {
|
||||||
|
configSave = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if dirty {
|
||||||
|
configSave = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Printf("dirty check (%d repos) took:%s\n", count, shell.FormatDuration(time.Since(now)))
|
||||||
|
me.forge.SetConfigSave(configSave)
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func doExamine() bool {
|
||||||
|
me.found = new(gitpb.Repos)
|
||||||
|
all := me.forge.Repos.SortByFullPath()
|
||||||
|
for all.Scan() {
|
||||||
|
repo := all.Next()
|
||||||
|
if tag := repo.ExamineBranches(); tag != nil {
|
||||||
|
me.found.AppendByGoPath(repo)
|
||||||
|
ctime := tag.Creatordate.AsTime()
|
||||||
|
dur := time.Since(ctime)
|
||||||
|
log.Printf("UNKNOWN BRANCH %-50s %s %4s %s\n", repo.GetFullPath(), tag.Hash, shell.FormatDuration(dur), tag.Refname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(me.found.Repos) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
me.forge.PrintHumanTableDirty(me.found)
|
||||||
|
return false
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func doGitPull() {
|
||||||
|
allerr := me.found.RillGitPull(40, 5)
|
||||||
|
|
||||||
|
all := me.found.SortByFullPath()
|
||||||
|
for all.Scan() {
|
||||||
|
repo := all.Next()
|
||||||
|
result := allerr[repo]
|
||||||
|
if result.Error == gitpb.ErrorGitPullOnDirty {
|
||||||
|
log.Info("skip git pull. repo is dirty", repo.GetGoPath())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if result.Error == gitpb.ErrorGitPullOnLocal {
|
||||||
|
log.Info("skip git pull. local branch ", repo.GetGoPath())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if result.Exit == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("git pull error:", repo.GetGoPath(), result.Error)
|
||||||
|
log.Info("git pull error:", repo.GetGoPath(), result.Stdout)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
11
main.go
11
main.go
|
@ -122,11 +122,12 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Dirty != nil {
|
if argv.Dirty != nil {
|
||||||
findAll() // select all the repos
|
doDirty()
|
||||||
doCheckDirtyAndConfigSave()
|
okExit("")
|
||||||
me.found = new(gitpb.Repos)
|
}
|
||||||
findDirty()
|
|
||||||
me.forge.PrintHumanTableDirty(me.found)
|
if argv.Examine != nil {
|
||||||
|
doExamine()
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue