1package operations
2
3import (
4 "github.com/MichaelMure/git-bug/bug"
5 "time"
6)
7
8// CreateOperation define the initial creation of a bug
9
10var _ bug.Operation = CreateOperation{}
11
12type CreateOperation struct {
13 bug.OpBase
14 Title string
15 Message string
16 Author bug.Person
17 Time int64
18}
19
20func NewCreateOp(author bug.Person, title, message string) CreateOperation {
21 return CreateOperation{
22 OpBase: bug.OpBase{OperationType: bug.CreateOp},
23 Title: title,
24 Message: message,
25 Author: author,
26 Time: time.Now().Unix(),
27 }
28}
29
30func (op CreateOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
31 snapshot.Title = op.Title
32 snapshot.Comments = []bug.Comment{
33 {
34 Message: op.Message,
35 Author: op.Author,
36 Time: op.Time,
37 },
38 }
39 return snapshot
40}