blob: 66725915b269947e5b63ed5dbd68c7e0d9fa78e6 (
plain) (
blame)
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
|
package operations
import (
"github.com/MichaelMure/git-bug/bug"
)
// AddCommentOperation will add a new comment in the bug
var _ bug.Operation = AddCommentOperation{}
type AddCommentOperation struct {
bug.OpBase
Message string
}
func NewAddCommentOp(author bug.Person, message string) AddCommentOperation {
return AddCommentOperation{
OpBase: bug.NewOpBase(bug.AddCommentOp, author),
Message: message,
}
}
func (op AddCommentOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
comment := bug.Comment{
Message: op.Message,
Author: op.Author,
UnixTime: op.UnixTime,
}
snapshot.Comments = append(snapshot.Comments, comment)
return snapshot
}
func Comment(b *bug.Bug, author bug.Person, message string) {
addCommentOp := NewAddCommentOp(author, message)
b.Append(addCommentOp)
}
|