summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-26 23:43:29 -0500
committerJeff Carr <[email protected]>2025-09-26 23:43:29 -0500
commit9eabff46459a912b09aa7937199134b01d09def0 (patch)
tree869c7d3b2b427d69c5230009f4f1b695930945fe
parent54a4c94ec3b140ff6156e8ec324ec3b1df15955d (diff)
save Tags.Master & Tags.Devel
-rw-r--r--Makefile2
-rw-r--r--doNormal.go11
-rw-r--r--doPull.go82
3 files changed, 61 insertions, 34 deletions
diff --git a/Makefile b/Makefile
index f20cf8d..a1cd2b2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
# make andlabs # try the andlabs gui plugin (uses GTK)
default: install-verbose
- forge pull list
+ forge pull check
vet:
@GO111MODULE=off go vet
diff --git a/doNormal.go b/doNormal.go
index 33cbcf6..06fec11 100644
--- a/doNormal.go
+++ b/doNormal.go
@@ -17,6 +17,7 @@ import (
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
+ "google.golang.org/protobuf/proto"
)
func doNormal() bool {
@@ -130,6 +131,16 @@ func checkNormalRepoState(repo *gitpb.Repo) error {
return ErrorLocalMasterBranch
}
+ if repo.Tags.Master == nil {
+ if found := repo.GetRemoteTag(repo.GetMasterBranchName()); found != nil {
+ log.Info("found master tag ", repo.FullPath, found)
+ repo.Tags.Master = proto.Clone(found).(*gitpb.GitTag)
+ config.SetChanged("repos", true)
+ } else {
+ log.Info("not found master tag", repo.FullPath)
+ }
+ }
+
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
log.Infof("changing to user(%s) branch: %s\n", repo.GetUserBranchName(), repo.FullPath)
repo.CheckoutUser()
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
}
-*/