diff --git a/argv.go b/argv.go index 5d71db3..0f4d357 100644 --- a/argv.go +++ b/argv.go @@ -19,6 +19,7 @@ type args struct { List *FindCmd `arg:"subcommand:list" help:"just show a table of the current state"` Patch *PatchCmd `arg:"subcommand:patch" help:"examine and make patch sets"` GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"` + GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"` 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' (errors out if on wrong branch)"` diff --git a/argvAutoshell.go b/argvAutoshell.go index 725efdb..2e80fdf 100644 --- a/argvAutoshell.go +++ b/argvAutoshell.go @@ -38,7 +38,7 @@ func (args) doBashAuto() { case "list": fmt.Println("--all --mine --favorites --private patches") case "pull": - fmt.Println("--all --mine --favorites --private") + fmt.Println("--verbose") case "patch": fmt.Println("list --submit show") case "user": diff --git a/doCheckout.go b/doCheckout.go index 40522e7..eb85818 100644 --- a/doCheckout.go +++ b/doCheckout.go @@ -199,14 +199,16 @@ func rillCheckoutMaster(repo *gitpb.Repo) error { repo.CheckoutMaster() return nil } - if repo.GetUserVersion() != repo.GetDevelVersion() { - // don't switch branches if the user branch has uncommitted patches - return nil - } - if repo.GetDevelVersion() != repo.GetMasterVersion() { - // don't switch braches if the devel branch does not match master (needs merge) - return nil - } + /* + if repo.GetUserVersion() != repo.GetDevelVersion() { + // don't switch branches if the user branch has uncommitted patches + return nil + } + if repo.GetDevelVersion() != repo.GetMasterVersion() { + // don't switch braches if the devel branch does not match master (needs merge) + return nil + } + */ repo.CheckoutMaster() return nil } diff --git a/doPull.go b/doPull.go index 09ade34..1604800 100644 --- a/doPull.go +++ b/doPull.go @@ -1,10 +1,50 @@ package main import ( + "time" + + "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) +func rillPull(repo *gitpb.Repo) error { + if repo.IsDirty() { + // never do dirty repos + return nil + } + t, _ := repo.LastGitPull() + if time.Since(t) < time.Hour { + if argv.Verbose { + log.Info(repo.GetFullPath(), "git pulled too recently", shell.FormatDuration(time.Since(t))) + } + return nil + } + + var cmd []string + cmd = append(cmd, "git", "pull") + _, err := repo.RunVerbose(cmd) + if err != nil { + log.Info(repo.GetFullPath(), "git pull err:", err) + } + return nil +} + +// is every repo on the devel branch? + +func doGitPullNew() { + now := time.Now() + me.forge.RillFuncError(rillPull) + count := me.forge.RillReload() + if count != 0 { + me.forge.ConfigSave() + } + + total, count, nope, _ := IsEverythingOnMaster() + log.Printf("Master branch check. %d total repos. (%d git pulled) (%d not on master branch) (%s)\n", total, count, nope, shell.FormatDuration(time.Since(now))) +} + +/* func doGitPull() { allerr := me.found.RillGitPull(40, 5) @@ -29,6 +69,7 @@ func doGitPull() { } } +*/ // git fetch origin master:master func rillFetchMaster(repo *gitpb.Repo) error { diff --git a/main.go b/main.go index 0313596..4493572 100644 --- a/main.go +++ b/main.go @@ -119,12 +119,18 @@ func main() { okExit("") } - if argv.GitPull != nil { + if argv.GitFetch != nil { // argv.GitPull.findRepos() doGitFetch() okExit("") } + if argv.GitPull != nil { + // argv.GitPull.findRepos() + doGitPullNew() + okExit("") + } + if argv.GitReset != nil { findAll() // select all the repos doGitReset()