summaryrefslogtreecommitdiff
path: root/doPull.go
diff options
context:
space:
mode:
Diffstat (limited to 'doPull.go')
-rw-r--r--doPull.go82
1 files changed, 49 insertions, 33 deletions
diff --git a/doPull.go b/doPull.go
index e4e248d..28d2585 100644
--- a/doPull.go
+++ b/doPull.go
@@ -10,28 +10,26 @@ import (
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
+ "google.golang.org/protobuf/proto"
)
// is every repo on the devel branch?
func doPull() error {
if argv.Pull.Check != nil {
- // 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 := prepareCheckRepos()
updatepb, regPB, err := submit.HttpPost(myServer(), "check")
- if regPB == nil || err != nil {
- log.Info("regPB==nil or err:", err)
- return nil
+ 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
}
- 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 %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())
return nil
}
if argv.Pull.List != nil {
@@ -72,6 +70,20 @@ func doPull() error {
}
+func findGitTag(repo *gitpb.Repo, hash string) *gitpb.GitTag {
+ for _, tag := range repo.Tags.GitTags {
+ if tag.Hash == hash {
+ return tag
+ }
+ // log.Info(i, tag.Hash, tag.Refname, tag)
+ }
+ for i, tag := range repo.Tags.GitTags {
+ log.Info(hash, i, tag)
+ }
+ okExit("")
+ return nil
+}
+
func rillPull(repo *gitpb.Repo) error {
if repo.IsDirty() {
// never do dirty repos
@@ -101,24 +113,28 @@ func rillPull(repo *gitpb.Repo) error {
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 prepareCheckRepos() *gitpb.Repos {
+ submit := gitpb.NewRepos()
+ for repo := range me.forge.Repos.IterByFullPath() {
+ newrepo := new(gitpb.Repo)
+ newrepo.Namespace = repo.Namespace
+ newrepo.URL = repo.URL
+ newrepo.Tags = gitpb.NewGitTags()
-func doGitFetch() {
- me.forge.RillFuncError(rillFetchMaster)
- count := me.forge.RillReload()
- if count != 0 {
- me.forge.ConfigSave()
+ if repo.Tags == nil {
+ log.Infof("%s no tags\n", repo.FullPath)
+ continue
+ }
+
+ if repo.Tags.Master != nil {
+ newrepo.Tags.Master = proto.Clone(repo.Tags.Master).(*gitpb.GitTag)
+ } else {
+ log.Infof("no master tag %s\n", repo.FullPath)
+ }
+ if repo.Tags.Devel != nil {
+ newrepo.Tags.Devel = proto.Clone(repo.Tags.Devel).(*gitpb.GitTag)
+ }
+ submit.Append(newrepo)
}
+ return submit
}
-*/