diff options
| author | Jeff Carr <[email protected]> | 2025-09-08 00:03:54 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-08 00:03:54 -0500 |
| commit | 2c7d1de63778214fd355deef61680d7e18e4a275 (patch) | |
| tree | c9aad6d8ac79b2f62735419f54c6d550fdc3be7d /doPull.go | |
| parent | 99de9e31bcf91bc35ecc67c671d86b3836844a06 (diff) | |
redo doPull()
Diffstat (limited to 'doPull.go')
| -rw-r--r-- | doPull.go | 73 |
1 files changed, 61 insertions, 12 deletions
@@ -4,24 +4,22 @@ 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" ) // is every repo on the devel branch? -func doGitPull() error { - if me.forge.Config.Mode != forgepb.ForgeMode_MASTER { - if argv.Force == true { - log.Info("okay. you have forced the issue") - } else { - log.Info("forge requres being on the master branch") - log.Info("you must run:") - log.Info("") - log.Info("forge checkout master") - log.Info("") - return nil - } +func doPull() error { + if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL { + log.Info("you must check out the devel or master branches") + return nil + } + if argv.Force == true { + log.Info("okay. you have forced the issue") } // stats := me.forge.RillFuncError(rillPull) @@ -39,3 +37,54 @@ func doGitPull() error { return nil } + +func rillPull(repo *gitpb.Repo) error { + if repo.IsDirty() { + // never do dirty repos + return nil + } + t, _ := repo.LastGitPull() + if time.Since(t) < time.Minute*10 && !argv.Force { + if argv.Verbose { + log.Info(repo.GetFullPath(), "git pulled too recently", shell.FormatDuration(time.Since(t))) + } + return nil + } + cur := repo.GetCurrentBranchName() + if !repo.IsBranchRemote(cur) { + if argv.Verbose { + log.Info(repo.GetFullPath(), "branch is not remote", cur) + } + 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 +} + +/* +// git fetch origin master:master +func rillFetchMaster(repo *gitpb.Repo) error { + if repo.GetCurrentBranchName() != repo.GetUserBranchName() { + // only fetch when branch is on the user branch + return nil + } + branch := repo.GetMasterBranchName() + cmd := []string{"git", "fetch", "origin", branch + ":" + branch} + err := repo.RunVerbose(cmd) + return err +} + +func doGitFetch() { + me.forge.RillFuncError(rillFetchMaster) + count := me.forge.RillReload() + if count != 0 { + me.forge.ConfigSave() + } +} +*/ |
