diff options
| author | Jeff Carr <[email protected]> | 2025-01-28 21:50:07 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-29 12:18:16 -0600 |
| commit | 438a8812f6cbd83556ad2d146068e8eca37ca2f4 (patch) | |
| tree | e7012823f56b3237f19b358ef5b9f206230f9c4c | |
| parent | eee88af0ce0afd82046985572d2bea0090c7e087 (diff) | |
smarter git pull
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | applyPatch.go | 23 | ||||
| -rw-r--r-- | doPull.go | 9 | ||||
| -rw-r--r-- | windowPatches.go | 4 |
4 files changed, 22 insertions, 16 deletions
@@ -33,7 +33,7 @@ plugin: rm -f resources/*.so cp ../../toolkits/gocui/gocui.so resources/ -andlabs: +andlabs: install forge --gui andlabs gocui: install diff --git a/applyPatch.go b/applyPatch.go index f1beba9..5ad452d 100644 --- a/applyPatch.go +++ b/applyPatch.go @@ -12,34 +12,33 @@ import ( ) // saves the patches in ~/.config/forge/currentpatches/ -func savePatchset(pset *forgepb.Patchset) bool { - log.Info("applyPatches() NAME", pset.Name) - log.Info("applyPatches() COMMENT", pset.Comment) - log.Info("applyPatches() GIT_AUTHOR_NAME", pset.GetGitAuthorName()) - log.Info("applyPatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail()) - log.Info("applyPatches() Branch Name", pset.GetStartBranchName()) - log.Info("applyPatches() Start Hash", pset.GetStartBranchHash()) +func savePatchset(pset *forgepb.Patchset) error { + log.Info("savePatches() NAME", pset.Name) + log.Info("savePatches() COMMENT", pset.Comment) + log.Info("savePatches() GIT_AUTHOR_NAME", pset.GetGitAuthorName()) + log.Info("savePatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail()) + log.Info("savePatches() Branch Name", pset.GetStartBranchName()) + log.Info("savePatches() Start Hash", pset.GetStartBranchHash()) var count int var bad int + var lasterr error all := pset.Patches.SortByFilename() for all.Scan() { p := all.Next() - // basedir := me.forge.GetGoSrc() basedir := filepath.Join(os.Getenv("FORGE_CONFIG"), "currentpatches") if fullname, err := savePatchFile(p, basedir); err != nil { log.Info(fullname, "save failed", err) - continue - } else { bad += 1 + lasterr = err } count += 1 } log.Info("pset has", count, "total patches, ", bad, "bad save patches") if bad == 0 { - return true + return lasterr } - return false + return nil } // returns bad if patches can not be applied @@ -14,12 +14,19 @@ func rillPull(repo *gitpb.Repo) error { return nil } t, _ := repo.LastGitPull() - if time.Since(t) < time.Minute*10 { + 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") diff --git a/windowPatches.go b/windowPatches.go index bcb41bb..793afb8 100644 --- a/windowPatches.go +++ b/windowPatches.go @@ -130,8 +130,8 @@ func (r *patchesWindow) addPatchset(line string) { log.Info(name, "was nil") return } - if !savePatchset(pset) { - log.Info("Save: some patches are bad", name) + if err := savePatchset(pset); err != nil { + log.Info("Save: some patches are bad", name, err) return } }) |
