git-bug/bug/operations/add_comment.go

37 lines
701 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"
"time"
)
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
Author bug.Person
Time time.Time
2018-07-13 23:53:53 +03:00
}
func NewAddCommentOp(author bug.Person, message string) AddCommentOperation {
return AddCommentOperation{
OpBase: bug.OpBase{OperationType: bug.ADD_COMMENT},
Message: message,
Author: author,
2018-07-14 23:18:40 +03:00
Time: time.Now(),
2018-07-13 23:53:53 +03:00
}
}
func (op AddCommentOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
comment := bug.Comment{
Message: op.Message,
Author: op.Author,
2018-07-14 23:18:40 +03:00
Time: op.Time,
2018-07-13 23:53:53 +03:00
}
snapshot.Comments = append(snapshot.Comments, comment)
return snapshot
}