/
commitlist.go
72 lines (61 loc) · 1.24 KB
/
commitlist.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package git4go
import (
"sort"
)
type CommitListFlag uint
const (
Parent1 CommitListFlag = 1 << iota
Parent2 CommitListFlag = 1 << iota
Result CommitListFlag = 1 << iota
Stale CommitListFlag = 1 << iota
)
type commitListNode struct {
oid *Oid
time uint64
seen bool
uninteresting bool
topologyDelay bool
parsed bool
inDegree int
flags CommitListFlag
parents []*commitListNode
}
type commitListNodes []*commitListNode
func (q commitListNodes) interesting() bool {
for _, commit := range q {
if (commit.flags & Stale) == 0 {
return true
}
}
return false
}
func (q commitListNodes) contains(node *commitListNode) bool {
for _, commit := range q {
if commit == node {
return true
}
}
return false
}
func (q commitListNodes) interestingArr() bool {
for _, n := range q {
if !n.uninteresting {
return true
}
}
return false
}
func (q commitListNodes) Len() int {
return len(q)
}
func (q commitListNodes) Swap(i, j int) {
q[i], q[j] = q[j], q[i]
}
func (q commitListNodes) Less(i, j int) bool {
return q[i].time > q[j].time
}
func (q commitListNodes) insertByTime(commit *commitListNode) commitListNodes {
result := append(q, commit)
sort.Sort(result)
return result
}