diff options
| author | Jeff Carr <[email protected]> | 2025-10-02 17:36:49 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-02 17:36:49 -0500 |
| commit | 3b0ff7d584dd517a1fff2330f19f32783b524c5c (patch) | |
| tree | 8175d53d6993c89728a1d0c9e478c10d27958e5b /doPull.go | |
| parent | 785e7102c58df7fdfe973a8f3ad8a7af2181e918 (diff) | |
this is hard
Diffstat (limited to 'doPull.go')
| -rw-r--r-- | doPull.go | 46 |
1 files changed, 35 insertions, 11 deletions
@@ -12,6 +12,21 @@ import ( "go.wit.com/log" ) +func updateURL(repo *gitpb.Repo) bool { + found := me.forge.Repos.FindByNamespace(repo.Namespace) + if found == nil { + return false + } + if repo.URL == found.URL { + return false + } + cmd := []string{"git", "remote", "set-url", "origin", repo.URL} + found.URL = repo.URL + log.Infof("%s update URL to %v\n", found.URL, cmd) + found.Run(cmd) + return true +} + // returns true if 'git pull' should be run func needToUpdateRepo(repo *gitpb.Repo) (*gitpb.Repo, error) { if repo.Tags == nil { @@ -83,19 +98,28 @@ func doPull() error { // 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 { + if updateURL(repo) { + count += 1 continue } - // found.RunVerbose([]string{"git", "pull", "origin", found.GetMasterBranchName()}) - found.CheckoutMaster() - found.GitPull() - found.ReloadCheck() - found.GitPull() - if count > 10 { - break - } - count += 1 + /* + found, _ := needToUpdateRepo(repo) + if found == nil { + continue + } + if !argv.Force { + 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 |
