git-bug/bug/operations/add_comment.go

34 lines
674 B
Go
Raw Normal View History

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
// 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{
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{
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
}