summaryrefslogtreecommitdiff
path: root/compare.go
blob: 340206dc4a174ebed5e7f1b2f759111c420421fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
}