2018-07-13 23:53:53 +03:00
|
|
|
package operations
|
|
|
|
|
2018-07-14 23:18:40 +03:00
|
|
|
import (
|
|
|
|
"github.com/MichaelMure/git-bug/bug"
|
|
|
|
)
|
2018-07-13 23:53:53 +03:00
|
|
|
|
2018-07-18 01:16:06 +03:00
|
|
|
// AddCommentOperation will add a new comment in the bug
|
|
|
|
|
2018-07-13 23:53:53 +03:00
|
|
|
var _ bug.Operation = AddCommentOperation{}
|
|
|
|
|
|
|
|
type AddCommentOperation struct {
|
|
|
|
bug.OpBase
|
2018-07-14 23:18:40 +03:00
|
|
|
Message string
|
2018-07-13 23:53:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewAddCommentOp(author bug.Person, message string) AddCommentOperation {
|
|
|
|
return AddCommentOperation{
|
2018-07-18 01:16:06 +03:00
|
|
|
OpBase: bug.NewOpBase(bug.AddCommentOp, author),
|
2018-07-13 23:53:53 +03:00
|
|
|
Message: message,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (op AddCommentOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
|
|
|
|
comment := bug.Comment{
|
2018-07-18 01:16:06 +03:00
|
|
|
Message: op.Message,
|
|
|
|
Author: op.Author,
|
|
|
|
UnixTime: op.UnixTime,
|
2018-07-13 23:53:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
snapshot.Comments = append(snapshot.Comments, comment)
|
|
|
|
|
|
|
|
return snapshot
|
|
|
|
}
|
2018-07-25 19:01:32 +03:00
|
|
|
|
|
|
|
func Comment(b *bug.Bug, author bug.Person, message string) {
|
|
|
|
addCommentOp := NewAddCommentOp(author, message)
|
|
|
|
b.Append(addCommentOp)
|
|
|
|
}
|