aboutsummaryrefslogtreecommitdiffstats
path: root/bug/op_label_change.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-30 17:15:54 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-30 17:15:54 +0200
commit7f86898ef9a8f9e866835ece3c9824a8edc58036 (patch)
tree5c5733c9272f3477317935bde6ecb4680276b717 /bug/op_label_change.go
parentd71bb7dd7632780cf5aad5fda84027fa03a9d0f0 (diff)
downloadgit-bug-7f86898ef9a8f9e866835ece3c9824a8edc58036.tar.gz
bug: use deditated type for all TimelineItem
Diffstat (limited to 'bug/op_label_change.go')
-rw-r--r--bug/op_label_change.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/bug/op_label_change.go b/bug/op_label_change.go
index 5f2dbd6f..b025be81 100644
--- a/bug/op_label_change.go
+++ b/bug/op_label_change.go
@@ -55,7 +55,22 @@ AddLoop:
return string(snapshot.Labels[i]) < string(snapshot.Labels[j])
})
- snapshot.Timeline = append(snapshot.Timeline, op)
+ hash, err := op.Hash()
+ if err != nil {
+ // Should never error unless a programming error happened
+ // (covered in OpBase.Validate())
+ panic(err)
+ }
+
+ item := &LabelChangeTimelineItem{
+ hash: hash,
+ Author: op.Author,
+ UnixTime: Timestamp(op.UnixTime),
+ Added: op.Added,
+ Removed: op.Removed,
+ }
+
+ snapshot.Timeline = append(snapshot.Timeline, item)
}
func (op *LabelChangeOperation) Validate() error {
@@ -90,6 +105,18 @@ func NewLabelChangeOperation(author Person, unixTime int64, added, removed []Lab
}
}
+type LabelChangeTimelineItem struct {
+ hash git.Hash
+ Author Person
+ UnixTime Timestamp
+ Added []Label
+ Removed []Label
+}
+
+func (l LabelChangeTimelineItem) Hash() git.Hash {
+ return l.hash
+}
+
// ChangeLabels is a convenience function to apply the operation
func ChangeLabels(b Interface, author Person, unixTime int64, add, remove []string) ([]LabelChangeResult, error) {
var added, removed []Label