fixes from cleaning an old set of repos

This commit is contained in:
Jeff Carr 2025-01-28 11:26:31 -06:00
parent dd7355571d
commit 7402aaded7
5 changed files with 60 additions and 10 deletions

View File

@ -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)"`

View File

@ -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":

View File

@ -199,6 +199,7 @@ 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
@ -207,6 +208,7 @@ func rillCheckoutMaster(repo *gitpb.Repo) error {
// don't switch braches if the devel branch does not match master (needs merge)
return nil
}
*/
repo.CheckoutMaster()
return nil
}

View File

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

View File

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