summaryrefslogtreecommitdiff
path: root/doPull.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-07 12:05:36 -0500
committerJeff Carr <[email protected]>2025-09-07 12:05:36 -0500
commitdb758bbed22ad2542e80f927a2d27f5be19ddd5b (patch)
tree95ef2269d785247d26a21e1bbff29755ebc87b7c /doPull.go
parent3df2601f274645fd9db9b791aa76b62b5f3b6f3a (diff)
work on "forge pull"
Diffstat (limited to 'doPull.go')
-rw-r--r--doPull.go162
1 files changed, 22 insertions, 140 deletions
diff --git a/doPull.go b/doPull.go
index 029a9e1..bacaf8e 100644
--- a/doPull.go
+++ b/doPull.go
@@ -4,156 +4,38 @@
package main
import (
- "fmt"
- "time"
-
- "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/forgepb"
"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.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
-}
-
// is every repo on the devel branch?
-
func doGitPull() error {
- if argv.Pull == nil {
- return fmt.Errorf("not really 'fetch pull'")
- }
-
- if argv.Force {
- now := time.Now()
- stats := me.forge.RillFuncError(rillPull)
- count := me.forge.RillReload()
- if count != 0 {
- me.forge.ConfigSave()
+ 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
}
-
- total, count, nope, _ := me.forge.IsEverythingOnMaster()
- log.Printf("Master branch check. %d total repos. (%d git pulled) (%d not on master branch) (%s) git pull total=FIXME%d\n", total, count, nope, shell.FormatDuration(time.Since(now)), len(stats))
- return nil
- }
-
- check := gitpb.NewRepos()
-
- if argv.Pull.Dirty != nil {
- check = me.forge.FindDirty()
- }
-
- if argv.Pull.Patches != nil {
- check = findReposWithPatches()
- }
-
- if argv.Pull.Check != nil {
- // TODO: never wrote this yet
- // update, err := me.forge.CheckVersions()
- // return err
- return nil
- }
-
- if check.Len() == 0 {
- // check = doFind()
- check = findAll()
- // check = find50()
- // check = findMine()
}
- me.forge.PrintHumanTableFull(check)
- if argv.Pull.Dirty != nil {
- log.Info("dirty count =", check.Len())
- return nil
- }
-
- found, err := me.forge.LookupPB(check)
- if err != nil {
- log.Info("LookupPB() failed", err, "len(check)=", check.Len())
- return err
- }
- // me.forge.PrintHumanTableFull(found)
-
- // check to see if the repos need to be updated
- update := gitpb.NewRepos()
-
- if found.Len() == 0 {
- return nil
- }
- log.Info("found.Len() ==", found.Len())
-
- for repo := range found.IterAll() {
- masterb := repo.GetMasterBranchName()
- if masterb == "" {
- log.Info(repo.GetNamespace(), "master branch blank")
- continue
- }
- a := repo.GetLocalHash(masterb)
- ns := repo.GetNamespace()
- repo2 := me.forge.Repos.FindByNamespace(ns)
- if repo2 == nil {
- log.Info("repo namespace does not exist", a, repo.Namespace)
- continue
- }
- b := repo2.GetLocalHash(repo2.GetMasterBranchName())
- if b == a {
- continue
- }
- log.Info(a, "!=", b, repo.Namespace)
- update.AppendByNamespace(repo2)
- }
- if update.Len() == 0 {
- // nothing to update
- return nil
- }
- if _, err := me.forge.UpdatePB(update); err != nil {
- log.Info("UpdatePB() failed", err, "len(check)=", update.Len())
- return err
+ // stats := me.forge.RillFuncError(rillPull)
+ log.Info("TODO: actually git pull here? this is a bad idea. stopping.")
+ submit := gitpb.NewRepos()
+ for repo := range me.forge.Repos.IterByFullPath() {
+ newrepo := new(gitpb.Repo)
+ newrepo.MasterHash = repo.MasterHash
+ newrepo.DevelHash = repo.DevelHash
+ newrepo.Namespace = repo.Namespace
+ newrepo.URL = repo.URL
+ submit.Append(newrepo)
}
+ submit.HttpPost(myServer(), "check")
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()
- }
-}