aboutsummaryrefslogtreecommitdiffstats
path: root/bug/op_set_title.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_set_title.go
parentd71bb7dd7632780cf5aad5fda84027fa03a9d0f0 (diff)
downloadgit-bug-7f86898ef9a8f9e866835ece3c9824a8edc58036.tar.gz
bug: use deditated type for all TimelineItem
Diffstat (limited to 'bug/op_set_title.go')
-rw-r--r--bug/op_set_title.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/bug/op_set_title.go b/bug/op_set_title.go
index 74467ec2..fd964a30 100644
--- a/bug/op_set_title.go
+++ b/bug/op_set_title.go
@@ -27,7 +27,23 @@ func (op *SetTitleOperation) Hash() (git.Hash, error) {
func (op *SetTitleOperation) Apply(snapshot *Snapshot) {
snapshot.Title = op.Title
- 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 := &SetTitleTimelineItem{
+ hash: hash,
+ Author: op.Author,
+ UnixTime: Timestamp(op.UnixTime),
+ Title: op.Title,
+ Was: op.Was,
+ }
+
+ snapshot.Timeline = append(snapshot.Timeline, item)
}
func (op *SetTitleOperation) Validate() error {
@@ -66,6 +82,18 @@ func NewSetTitleOp(author Person, unixTime int64, title string, was string) *Set
}
}
+type SetTitleTimelineItem struct {
+ hash git.Hash
+ Author Person
+ UnixTime Timestamp
+ Title string
+ Was string
+}
+
+func (s SetTitleTimelineItem) Hash() git.Hash {
+ return s.hash
+}
+
// Convenience function to apply the operation
func SetTitle(b Interface, author Person, unixTime int64, title string) error {
it := NewOperationIterator(b)