start an 'examine' argv

This commit is contained in:
Jeff Carr 2025-01-17 10:59:05 -06:00
parent af84727178
commit 9acbb24284
8 changed files with 114 additions and 63 deletions

View File

@ -2,7 +2,8 @@ VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
info: install
forge dirty
# forge dirty
forge examine
vet:
@GO111MODULE=off go vet

View File

@ -21,7 +21,8 @@ type args struct {
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
Rescan *EmptyCmd `arg:"subcommand:rescan" help:"recreate the git protobuf repos.pb file"`
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"`
All bool `arg:"--all" help:"git commit --all"`
Show string `arg:"--show" help:"show a repo"`

View File

@ -46,7 +46,7 @@ func (args) doBashAuto() {
default:
if argv.BashAuto[0] == ARGNAME {
// 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)

View File

@ -1,66 +1,11 @@
package main
import (
"time"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"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)
}
}
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 {
me.found = new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()

44
doDirty.go Normal file
View File

@ -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)
}

28
doExamine.go Normal file
View File

@ -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
}

31
doPull.go Normal file
View File

@ -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
View File

@ -122,11 +122,12 @@ func main() {
}
if argv.Dirty != nil {
findAll() // select all the repos
doCheckDirtyAndConfigSave()
me.found = new(gitpb.Repos)
findDirty()
me.forge.PrintHumanTableDirty(me.found)
doDirty()
okExit("")
}
if argv.Examine != nil {
doExamine()
okExit("")
}