diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-29 20:41:19 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-29 20:41:19 +0200 |
commit | c46d01f8c10e6363b680fa6876e91bd8eaf3bb3e (patch) | |
tree | dde41c1253534bf4ff36e39454f2bdbdf4b9590f /bug/op_label_change.go | |
parent | 41e61a67b63e4d6c517005cf6f427115a664bdb5 (diff) | |
download | git-bug-c46d01f8c10e6363b680fa6876e91bd8eaf3bb3e.tar.gz |
bug: implement comment edition
- add a new operation
- add a new "timeline" in the snapshot that hold a processed version of the operations
Diffstat (limited to 'bug/op_label_change.go')
-rw-r--r-- | bug/op_label_change.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/bug/op_label_change.go b/bug/op_label_change.go index 8909cf56..5f2dbd6f 100644 --- a/bug/op_label_change.go +++ b/bug/op_label_change.go @@ -8,7 +8,7 @@ import ( "github.com/pkg/errors" ) -var _ Operation = LabelChangeOperation{} +var _ Operation = &LabelChangeOperation{} // LabelChangeOperation define a Bug operation to add or remove labels type LabelChangeOperation struct { @@ -17,16 +17,16 @@ type LabelChangeOperation struct { Removed []Label `json:"removed"` } -func (op LabelChangeOperation) base() *OpBase { +func (op *LabelChangeOperation) base() *OpBase { return op.OpBase } -func (op LabelChangeOperation) Hash() (git.Hash, error) { +func (op *LabelChangeOperation) Hash() (git.Hash, error) { return hashOperation(op) } // Apply apply the operation -func (op LabelChangeOperation) Apply(snapshot *Snapshot) { +func (op *LabelChangeOperation) Apply(snapshot *Snapshot) { // Add in the set AddLoop: for _, added := range op.Added { @@ -54,9 +54,11 @@ AddLoop: sort.Slice(snapshot.Labels, func(i, j int) bool { return string(snapshot.Labels[i]) < string(snapshot.Labels[j]) }) + + snapshot.Timeline = append(snapshot.Timeline, op) } -func (op LabelChangeOperation) Validate() error { +func (op *LabelChangeOperation) Validate() error { if err := opBaseValidate(op, LabelChangeOp); err != nil { return err } @@ -80,8 +82,8 @@ func (op LabelChangeOperation) Validate() error { return nil } -func NewLabelChangeOperation(author Person, unixTime int64, added, removed []Label) LabelChangeOperation { - return LabelChangeOperation{ +func NewLabelChangeOperation(author Person, unixTime int64, added, removed []Label) *LabelChangeOperation { + return &LabelChangeOperation{ OpBase: newOpBase(LabelChangeOp, author, unixTime), Added: added, Removed: removed, |