summaryrefslogtreecommitdiff
path: root/doPull.go
diff options
context:
space:
mode:
Diffstat (limited to 'doPull.go')
-rw-r--r--doPull.go79
1 files changed, 3 insertions, 76 deletions
diff --git a/doPull.go b/doPull.go
index 17328fe..dd837b9 100644
--- a/doPull.go
+++ b/doPull.go
@@ -4,7 +4,6 @@
package main
import (
- "strings"
"time"
"go.wit.com/lib/config"
@@ -14,25 +13,6 @@ 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
- if argv.Fix {
- log.Infof("%s update URL to %v\n", found.URL, cmd)
- found.Run(cmd)
- return true
- }
- log.Infof("add --fix to update %s with %v\n", found.URL, cmd)
- return true
-}
-
// returns true if 'git pull' should be run
func needToUpdateRepo(repo *gitpb.Repo) (*gitpb.Repo, error) {
if repo.Tags == nil {
@@ -88,62 +68,8 @@ func doPull() error {
return nil
}
if argv.Pull.Check != nil {
- submit := me.forge.PrepareCheckRepos()
- updatepb, regPB, err := submit.HttpPost(myServer(), "check")
- if err != nil {
- log.Info("err =", err)
- }
- if regPB == nil {
- log.Info("regPB==nil")
- }
- if updatepb == nil {
- 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())
- updatecheck := gitpb.NewRepos()
- for repo := range updatepb.IterAll() {
- if updateURL(repo) {
- count += 1
- }
- if repo.Namespace == "" {
- log.Info("forge sent back empty namespace", repo)
- continue
- }
- found := me.forge.Repos.FindByNamespace(repo.Namespace)
- if found == nil {
- log.Info("you don't have namespace?", repo.Namespace)
- continue
- }
- if !strings.HasPrefix(found.Namespace, "go.wit.com") {
- continue
- }
- updatecheck.Append(repo)
- // spew.Dump(repo)
- // me.sh.GoodExit("")
- /*
- 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.PrintPullTable(updatecheck)
- return nil
+ err := doFixUrls()
+ return err
}
if argv.Pull.List != nil {
found := gitpb.NewRepos()
@@ -190,6 +116,7 @@ func doPull() error {
}
}
me.forge.PrintPullTable(repoerr)
+ me.forge.PrintForgedTable(repoerr)
me.sh.GoodExit("git pull done")
}