git-bug/bug/operations/add_comment.go
2018-07-18 00:16:06 +02:00

34 lines
674 B
Go

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
}