more doFind() cleanups
This commit is contained in:
parent
47b7222445
commit
d2a0aa3098
3
Makefile
3
Makefile
|
@ -57,3 +57,6 @@ identify-protobuf:
|
|||
|
||||
devel:
|
||||
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
|
||||
func IsAnythingDirty() bool {
|
||||
me.found = new(gitpb.Repos)
|
||||
findAll() // select all the repos
|
||||
doCheckDirtyAndConfigSave()
|
||||
found := findDirty()
|
||||
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'"`
|
||||
List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"`
|
||||
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"`
|
||||
URL string `arg:"--connect" help:"forge url"`
|
||||
All bool `arg:"--all" help:"git commit --all"`
|
||||
|
@ -67,6 +67,10 @@ type PatchCmd struct {
|
|||
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 {
|
||||
Path string `arg:"--path" help:"absolute 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":
|
||||
fmt.Println("--full")
|
||||
case "pull":
|
||||
fmt.Println("--force")
|
||||
fmt.Println("list --force")
|
||||
case "patch":
|
||||
fmt.Println("get list --submit show")
|
||||
case "user":
|
||||
|
|
|
@ -81,7 +81,7 @@ func IsEverythingOnUser() (int, int, int, error) {
|
|||
}
|
||||
|
||||
func doGitReset() {
|
||||
all := me.found.SortByFullPath()
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
)
|
||||
|
||||
func doDirty() {
|
||||
findAll() // select all the repos
|
||||
doCheckDirtyAndConfigSave()
|
||||
found := findDirty()
|
||||
if argv.Verbose {
|
||||
|
@ -26,7 +25,7 @@ func straightCheckDirty() int {
|
|||
var count int
|
||||
// var total int
|
||||
// now := time.Now()
|
||||
for repo := range me.found.IterAll() {
|
||||
for repo := range me.forge.Repos.IterAll() {
|
||||
// total += 1
|
||||
if repo.IsDirty() {
|
||||
count += 1
|
||||
|
@ -52,7 +51,7 @@ func doCheckDirtyAndConfigSave() {
|
|||
now := time.Now()
|
||||
me.forge.RillFuncError(doCheckDirty)
|
||||
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 {
|
||||
// todo: use internal forgepb configsave flag. should work?
|
||||
|
|
24
doPull.go
24
doPull.go
|
@ -4,6 +4,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
|
@ -42,7 +43,27 @@ func rillPull(repo *gitpb.Repo) error {
|
|||
|
||||
// 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()
|
||||
pullcount := me.forge.RillFuncError(rillPull)
|
||||
count := me.forge.RillReload()
|
||||
|
@ -52,6 +73,7 @@ func doGitPullNew() {
|
|||
|
||||
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)
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
29
find.go
29
find.go
|
@ -14,6 +14,23 @@ import (
|
|||
//
|
||||
// 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 {
|
||||
if f == nil {
|
||||
findMine()
|
||||
|
@ -21,8 +38,7 @@ func (f *FindCmd) findRepos() *gitpb.Repos {
|
|||
}
|
||||
|
||||
if f.All {
|
||||
findAll()
|
||||
return me.found
|
||||
return findAll()
|
||||
}
|
||||
|
||||
if f.Private {
|
||||
|
@ -49,8 +65,7 @@ func (f *FindCmd) findRepos() *gitpb.Repos {
|
|||
return me.found
|
||||
}
|
||||
|
||||
findAll()
|
||||
return me.found
|
||||
return findAll()
|
||||
}
|
||||
|
||||
func findPrivate() {
|
||||
|
@ -94,10 +109,12 @@ func findDirty() *gitpb.Repos {
|
|||
return found
|
||||
}
|
||||
|
||||
func findAll() {
|
||||
func findAll() *gitpb.Repos {
|
||||
found := gitpb.NewRepos()
|
||||
for repo := range me.forge.Repos.IterByFullPath() {
|
||||
me.found.AppendByGoPath(repo)
|
||||
found.AppendByGoPath(repo)
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
func findUser() {
|
||||
|
|
2
main.go
2
main.go
|
@ -125,7 +125,6 @@ func main() {
|
|||
}
|
||||
|
||||
if argv.Clean.GitReset != nil {
|
||||
findAll() // select all the repos
|
||||
doGitReset()
|
||||
okExit("reset")
|
||||
}
|
||||
|
@ -188,7 +187,6 @@ func main() {
|
|||
// basically, if you run just 'forge' it should open the GUI
|
||||
|
||||
// if opening the GUI, always check git for dirty repos
|
||||
findAll() // select all the repos
|
||||
doCheckDirtyAndConfigSave()
|
||||
doGui()
|
||||
okExit("")
|
||||
|
|
|
@ -67,9 +67,8 @@ func (r *foundWindow) initWindow() {
|
|||
})
|
||||
group1.NewButton("all", func() {
|
||||
log.Info("find all here")
|
||||
me.found = new(gitpb.Repos)
|
||||
findAll()
|
||||
me.forge.PrintHumanTable(me.found)
|
||||
found := findAll()
|
||||
me.forge.PrintHumanTable(found)
|
||||
})
|
||||
|
||||
r.grid = r.stack.RawGrid()
|
||||
|
|
Loading…
Reference in New Issue