more doFind() cleanups
This commit is contained in:
parent
47b7222445
commit
d2a0aa3098
3
Makefile
3
Makefile
|
@ -57,3 +57,6 @@ identify-protobuf:
|
||||||
|
|
||||||
devel:
|
devel:
|
||||||
forge clean devel --force --verbose
|
forge clean devel --force --verbose
|
||||||
|
|
||||||
|
pull: install
|
||||||
|
forge pull test
|
||||||
|
|
|
@ -48,8 +48,6 @@ func savePatchset(pset *forgepb.Patchset) error {
|
||||||
|
|
||||||
// re-run git CheckDirty() on everything
|
// re-run git CheckDirty() on everything
|
||||||
func IsAnythingDirty() bool {
|
func IsAnythingDirty() bool {
|
||||||
me.found = new(gitpb.Repos)
|
|
||||||
findAll() // select all the repos
|
|
||||||
doCheckDirtyAndConfigSave()
|
doCheckDirtyAndConfigSave()
|
||||||
found := findDirty()
|
found := findDirty()
|
||||||
if found.Len() == 0 {
|
if found.Len() == 0 {
|
||||||
|
|
6
argv.go
6
argv.go
|
@ -24,7 +24,7 @@ type args struct {
|
||||||
GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"`
|
GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"`
|
||||||
List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"`
|
List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"`
|
||||||
Patch *PatchCmd `arg:"subcommand:patch" help:"make patchsets"`
|
Patch *PatchCmd `arg:"subcommand:patch" help:"make patchsets"`
|
||||||
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
|
GitPull *PullCmd `arg:"subcommand:pull" help:"run 'git pull'"`
|
||||||
Sync *SyncCmd `arg:"subcommand:sync" help:"sync repos with upstream"`
|
Sync *SyncCmd `arg:"subcommand:sync" help:"sync repos with upstream"`
|
||||||
URL string `arg:"--connect" help:"forge url"`
|
URL string `arg:"--connect" help:"forge url"`
|
||||||
All bool `arg:"--all" help:"git commit --all"`
|
All bool `arg:"--all" help:"git commit --all"`
|
||||||
|
@ -67,6 +67,10 @@ type PatchCmd struct {
|
||||||
Submit string `arg:"--submit" help:"submit your commits"`
|
Submit string `arg:"--submit" help:"submit your commits"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PullCmd struct {
|
||||||
|
Test *EmptyCmd `arg:"subcommand:test" help:"list repos that need 'git pull'"`
|
||||||
|
}
|
||||||
|
|
||||||
type ConfigAddCmd struct {
|
type ConfigAddCmd struct {
|
||||||
Path string `arg:"--path" help:"absolute path of the git repo"`
|
Path string `arg:"--path" help:"absolute path of the git repo"`
|
||||||
GoPath string `arg:"--gopath" help:"GO path of the git repo"`
|
GoPath string `arg:"--gopath" help:"GO path of the git repo"`
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (args) doBashAuto() {
|
||||||
case "list":
|
case "list":
|
||||||
fmt.Println("--full")
|
fmt.Println("--full")
|
||||||
case "pull":
|
case "pull":
|
||||||
fmt.Println("--force")
|
fmt.Println("list --force")
|
||||||
case "patch":
|
case "patch":
|
||||||
fmt.Println("get list --submit show")
|
fmt.Println("get list --submit show")
|
||||||
case "user":
|
case "user":
|
||||||
|
|
|
@ -81,7 +81,7 @@ func IsEverythingOnUser() (int, int, int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func doGitReset() {
|
func doGitReset() {
|
||||||
all := me.found.SortByFullPath()
|
all := me.forge.Repos.SortByFullPath()
|
||||||
for all.Scan() {
|
for all.Scan() {
|
||||||
repo := all.Next()
|
repo := all.Next()
|
||||||
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func doDirty() {
|
func doDirty() {
|
||||||
findAll() // select all the repos
|
|
||||||
doCheckDirtyAndConfigSave()
|
doCheckDirtyAndConfigSave()
|
||||||
found := findDirty()
|
found := findDirty()
|
||||||
if argv.Verbose {
|
if argv.Verbose {
|
||||||
|
@ -26,7 +25,7 @@ func straightCheckDirty() int {
|
||||||
var count int
|
var count int
|
||||||
// var total int
|
// var total int
|
||||||
// now := time.Now()
|
// now := time.Now()
|
||||||
for repo := range me.found.IterAll() {
|
for repo := range me.forge.Repos.IterAll() {
|
||||||
// total += 1
|
// total += 1
|
||||||
if repo.IsDirty() {
|
if repo.IsDirty() {
|
||||||
count += 1
|
count += 1
|
||||||
|
@ -52,7 +51,7 @@ func doCheckDirtyAndConfigSave() {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
me.forge.RillFuncError(doCheckDirty)
|
me.forge.RillFuncError(doCheckDirty)
|
||||||
end := straightCheckDirty()
|
end := straightCheckDirty()
|
||||||
log.Printf("dirty check (%d dirty repos) (%d total repos) took:%s\n", end, me.found.Len(), shell.FormatDuration(time.Since(now)))
|
log.Printf("dirty check (%d dirty repos) (%d total repos) took:%s\n", end, me.forge.Repos.Len(), shell.FormatDuration(time.Since(now)))
|
||||||
|
|
||||||
if start != end {
|
if start != end {
|
||||||
// todo: use internal forgepb configsave flag. should work?
|
// todo: use internal forgepb configsave flag. should work?
|
||||||
|
|
24
doPull.go
24
doPull.go
|
@ -4,6 +4,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
|
@ -42,7 +43,27 @@ func rillPull(repo *gitpb.Repo) error {
|
||||||
|
|
||||||
// is every repo on the devel branch?
|
// is every repo on the devel branch?
|
||||||
|
|
||||||
func doGitPullNew() {
|
func doGitPullNew() error {
|
||||||
|
if argv.GitPull == nil {
|
||||||
|
return fmt.Errorf("not really 'fetch pull'")
|
||||||
|
}
|
||||||
|
|
||||||
|
if argv.GitPull.Test != nil {
|
||||||
|
log.Info("list repo's with updates here")
|
||||||
|
found := doFind()
|
||||||
|
// me.forge.PrintHumanTable(found)
|
||||||
|
me.forge.PrintHumanTableFull(found)
|
||||||
|
/*
|
||||||
|
// print out the repos
|
||||||
|
if argv.List.Full {
|
||||||
|
me.forge.PrintHumanTableFull(found)
|
||||||
|
} else {
|
||||||
|
me.forge.PrintHumanTable(found)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
pullcount := me.forge.RillFuncError(rillPull)
|
pullcount := me.forge.RillFuncError(rillPull)
|
||||||
count := me.forge.RillReload()
|
count := me.forge.RillReload()
|
||||||
|
@ -52,6 +73,7 @@ func doGitPullNew() {
|
||||||
|
|
||||||
total, count, nope, _ := IsEverythingOnMaster()
|
total, count, nope, _ := IsEverythingOnMaster()
|
||||||
log.Printf("Master branch check. %d total repos. (%d git pulled) (%d not on master branch) (%s) git pull total=%d\n", total, count, nope, shell.FormatDuration(time.Since(now)), pullcount)
|
log.Printf("Master branch check. %d total repos. (%d git pulled) (%d not on master branch) (%s) git pull total=%d\n", total, count, nope, shell.FormatDuration(time.Since(now)), pullcount)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
29
find.go
29
find.go
|
@ -14,6 +14,23 @@ import (
|
||||||
//
|
//
|
||||||
// by default, it adds every repo
|
// by default, it adds every repo
|
||||||
|
|
||||||
|
func doFind() *gitpb.Repos {
|
||||||
|
if argv.List == nil {
|
||||||
|
return findAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
if argv.List.Mine {
|
||||||
|
findMine()
|
||||||
|
return me.found
|
||||||
|
}
|
||||||
|
|
||||||
|
if argv.List.Dirty {
|
||||||
|
return findDirty()
|
||||||
|
}
|
||||||
|
|
||||||
|
return findAll()
|
||||||
|
}
|
||||||
|
|
||||||
func (f *FindCmd) findRepos() *gitpb.Repos {
|
func (f *FindCmd) findRepos() *gitpb.Repos {
|
||||||
if f == nil {
|
if f == nil {
|
||||||
findMine()
|
findMine()
|
||||||
|
@ -21,8 +38,7 @@ func (f *FindCmd) findRepos() *gitpb.Repos {
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.All {
|
if f.All {
|
||||||
findAll()
|
return findAll()
|
||||||
return me.found
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.Private {
|
if f.Private {
|
||||||
|
@ -49,8 +65,7 @@ func (f *FindCmd) findRepos() *gitpb.Repos {
|
||||||
return me.found
|
return me.found
|
||||||
}
|
}
|
||||||
|
|
||||||
findAll()
|
return findAll()
|
||||||
return me.found
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func findPrivate() {
|
func findPrivate() {
|
||||||
|
@ -94,10 +109,12 @@ func findDirty() *gitpb.Repos {
|
||||||
return found
|
return found
|
||||||
}
|
}
|
||||||
|
|
||||||
func findAll() {
|
func findAll() *gitpb.Repos {
|
||||||
|
found := gitpb.NewRepos()
|
||||||
for repo := range me.forge.Repos.IterByFullPath() {
|
for repo := range me.forge.Repos.IterByFullPath() {
|
||||||
me.found.AppendByGoPath(repo)
|
found.AppendByGoPath(repo)
|
||||||
}
|
}
|
||||||
|
return found
|
||||||
}
|
}
|
||||||
|
|
||||||
func findUser() {
|
func findUser() {
|
||||||
|
|
2
main.go
2
main.go
|
@ -125,7 +125,6 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Clean.GitReset != nil {
|
if argv.Clean.GitReset != nil {
|
||||||
findAll() // select all the repos
|
|
||||||
doGitReset()
|
doGitReset()
|
||||||
okExit("reset")
|
okExit("reset")
|
||||||
}
|
}
|
||||||
|
@ -188,7 +187,6 @@ func main() {
|
||||||
// basically, if you run just 'forge' it should open the GUI
|
// basically, if you run just 'forge' it should open the GUI
|
||||||
|
|
||||||
// if opening the GUI, always check git for dirty repos
|
// if opening the GUI, always check git for dirty repos
|
||||||
findAll() // select all the repos
|
|
||||||
doCheckDirtyAndConfigSave()
|
doCheckDirtyAndConfigSave()
|
||||||
doGui()
|
doGui()
|
||||||
okExit("")
|
okExit("")
|
||||||
|
|
|
@ -67,9 +67,8 @@ func (r *foundWindow) initWindow() {
|
||||||
})
|
})
|
||||||
group1.NewButton("all", func() {
|
group1.NewButton("all", func() {
|
||||||
log.Info("find all here")
|
log.Info("find all here")
|
||||||
me.found = new(gitpb.Repos)
|
found := findAll()
|
||||||
findAll()
|
me.forge.PrintHumanTable(found)
|
||||||
me.forge.PrintHumanTable(me.found)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
r.grid = r.stack.RawGrid()
|
r.grid = r.stack.RawGrid()
|
||||||
|
|
Loading…
Reference in New Issue