summaryrefslogtreecommitdiff
path: root/compare.go
diff options
context:
space:
mode:
Diffstat (limited to 'compare.go')
-rw-r--r--compare.go45
1 files changed, 45 insertions, 0 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
+}