summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-05 17:25:40 -0500
committerJeff Carr <[email protected]>2025-10-05 17:25:40 -0500
commit7360716b35b452595e93c554d5f342b9f0338ea2 (patch)
tree48bfe292ce6ef174abe677ec669cad722d1f7c27
parentb76c20d78d97d0e8d81e51ab3084f9d364587bc5 (diff)
rm old code
-rw-r--r--compare.go45
-rw-r--r--gitTag.common.go6
-rw-r--r--reloadRepoState.go56
3 files changed, 48 insertions, 59 deletions
diff --git a/compare.go b/compare.go
new file mode 100644
index 0000000..340206d
--- /dev/null
+++ b/compare.go
@@ -0,0 +1,45 @@
+package gitpb
+
+type RepoTag struct {
+ r *Repo
+ t *GitTag
+}
+
+func (r *Repo) NewCompareTag(refname string) *RepoTag {
+ t := r.IfRefExists(refname)
+ if t == nil {
+ return nil
+ }
+ rt := new(RepoTag)
+ rt.r = r
+ rt.t = t
+ return rt
+}
+
+// if t1 is user branch, and t2 is devel branch, true if 0
+func (t1 *RepoTag) LessThan(t2 *RepoTag) bool {
+ count, err := t1.r.CountDiffObjects(t1.t.Refname, t2.t.Refname)
+ if err != nil {
+ return false
+ }
+ if count == 0 {
+ return true
+ }
+ return false
+}
+
+func (t1 *RepoTag) Equal(t2 *RepoTag) bool {
+ return false
+}
+
+// if t1 is user branch, and t2 is devel branch, true if 0
+func (t1 *RepoTag) GreaterThan(t2 *RepoTag) bool {
+ count, err := t1.r.CountDiffObjects(t2.t.Refname, t1.t.Refname)
+ if err != nil {
+ return false
+ }
+ if count == 0 {
+ return true
+ }
+ return false
+}
diff --git a/gitTag.common.go b/gitTag.common.go
index 5292b01..7535cd9 100644
--- a/gitTag.common.go
+++ b/gitTag.common.go
@@ -156,13 +156,13 @@ func (repo *Repo) IsRemoteBranch(findname string) bool {
return false
}
-func (repo *Repo) IfRefExists(refname string) bool {
+func (repo *Repo) IfRefExists(refname string) *GitTag {
for t := range repo.Tags.IterAll() {
if _, filename := filepath.Split(t.Refname); filename == refname {
- return true
+ return t
}
}
- return false
+ return nil
}
// finds the newest tag. used for deciding if master needs to be published
diff --git a/reloadRepoState.go b/reloadRepoState.go
index be1e612..37f24a3 100644
--- a/reloadRepoState.go
+++ b/reloadRepoState.go
@@ -2,62 +2,6 @@ package gitpb
// does processing on the go.mod and go.sum files
-/*
-// this is old crap that can finally be deprecated now that everything is protobuf
-func (repo *Repo) setRepoState() {
- if repo == nil {
- return
- }
- if repo.IsDirty() {
- repo.State = "dirty"
- return
- }
- if repo.GetUserVersion() == "" {
- // user has not set user branch name
- } else {
- if repo.GetUserVersion() != repo.GetDevelVersion() {
- repo.State = "merge to devel"
- return
- }
- }
- if repo.GetDevelVersion() != repo.GetMasterVersion() {
- if !repo.IsLocalBranch(repo.GetDevelBranchName()) {
- // the remote devel branch exists but is not checked out
- repo.State = "no devel branch"
- return
- }
- b1, err := repo.CountDiffObjects(repo.GetMasterBranchName(), repo.GetDevelBranchName())
- if err != nil {
- repo.State = "git log err"
- }
- if b1 == 0 {
- repo.State = "merge to main"
- // log.Info("master vs devel count is normal b1 == 0", b1)
- } else {
- repo.State = log.Sprintf("DEVEL < MASTER by %d", b1)
- // log.Info("master vs devel count b1 != 0", b1)
- log.Infof("%s devel branch is behind master branch (missing %d commits)\n", repo.GetGoPath(), b1)
- }
- return
- }
- // if IsGoTagVersionGreater(oldtag string, newtag string) bool {
- if !IsGoTagVersionGreater(repo.GetLastTag(), repo.GetMasterVersion()) {
- repo.State = "last tag greater error"
- return
- }
- if repo.GetLastTag() != repo.GetMasterVersion() {
- repo.State = "ready to release"
- return
- }
-
- if b := repo.CheckBranches(); b != "" {
- repo.State = "unknown branch " + b
- return
- }
- repo.State = "PERFECT"
-}
-*/
-
// returns true if old="v0.2.4" and new="v0.3.3"
// returns true if equal
// todo: make all of this smarter someday