mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 10:12:06 +03:00
37 lines
705 B
Go
37 lines
705 B
Go
package operations
|
|
|
|
import (
|
|
"github.com/MichaelMure/git-bug/bug"
|
|
"time"
|
|
)
|
|
|
|
var _ bug.Operation = AddCommentOperation{}
|
|
|
|
type AddCommentOperation struct {
|
|
bug.OpBase
|
|
Message string
|
|
Author bug.Person
|
|
Time int64
|
|
}
|
|
|
|
func NewAddCommentOp(author bug.Person, message string) AddCommentOperation {
|
|
return AddCommentOperation{
|
|
OpBase: bug.OpBase{OperationType: bug.AddCommentOp},
|
|
Message: message,
|
|
Author: author,
|
|
Time: time.Now().Unix(),
|
|
}
|
|
}
|
|
|
|
func (op AddCommentOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
|
|
comment := bug.Comment{
|
|
Message: op.Message,
|
|
Author: op.Author,
|
|
Time: op.Time,
|
|
}
|
|
|
|
snapshot.Comments = append(snapshot.Comments, comment)
|
|
|
|
return snapshot
|
|
}
|