diff options
| author | Jeff Carr <[email protected]> | 2025-09-27 10:53:12 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-27 10:53:12 -0500 |
| commit | c7d406fc290a95baffebb957be783f6a4974c46a (patch) | |
| tree | 58df8c0bd5ec5661a40eafb11ae2309623733c8f /doPull.go | |
| parent | 3cc5a7a142c26f853b470d2e2bd01f14a435fa12 (diff) | |
Diffstat (limited to 'doPull.go')
| -rw-r--r-- | doPull.go | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -12,6 +12,42 @@ import ( "go.wit.com/log" ) +// returns true if 'git pull' should be run +func needToUpdateRepo(repo *gitpb.Repo) (*gitpb.Repo, error) { + if repo.Tags == nil { + return nil, nil + } + if repo.Tags.Master == nil { + return nil, nil + } + found := me.forge.Repos.FindByNamespace(repo.Namespace) + if found == nil { + return nil, nil + } + if found.Tags == nil { + return nil, nil + } + if found.Tags.Master == nil { + return nil, nil + } + + newtime := repo.Tags.Master.Creatordate.AsTime() + ourtime := found.Tags.Master.Creatordate.AsTime() + + dur := newtime.Sub(ourtime) + if dur < time.Minute { + return nil, nil + } + log.Infof("checking for updates %s %s\n", shell.FormatDuration(dur), found.Namespace) + /* + dur := time.Since(repo.Tags.Master.Authordate.AsTime()) + when := repo.Tags.Master.Creatordate.AsTime() + dur = time.Since(when) + log.Infof("stuff %s age=%s %v\n", repo.Namespace, shell.FormatDuration(dur), when) + */ + return found, nil +} + // is every repo on the devel branch? func doPull() error { if argv.Pull.Check != nil { @@ -27,8 +63,25 @@ func doPull() error { log.Info("server sent nil back") return err } + var count int // log.Infof("pull check %s pb.Len()=%d client.Len()=%d server.Len()=%d err=%v\n", regPB.URL, updatepb.Len(), regPB.ClientDataLen, regPB.ServerDataLen, err) log.Infof("pull check pb.Len()=%d\n", updatepb.Len()) + for repo := range updatepb.IterAll() { + found, _ := needToUpdateRepo(repo) + if found == nil { + continue + } + // found.RunVerbose([]string{"git", "pull", "origin", found.GetMasterBranchName()}) + found.CheckoutMaster() + found.GitPull() + found.ReloadCheck() + found.GitPull() + if count > 10 { + break + } + count += 1 + } + me.forge.SaveRepos() return nil } if argv.Pull.List != nil { |
