1package operations
2
3import (
4 "github.com/MichaelMure/git-bug/bug"
5)
6
7// SetStatusOperation will change the status of a bug
8
9var _ bug.Operation = SetStatusOperation{}
10
11type SetStatusOperation struct {
12 bug.OpBase
13 Status bug.Status
14}
15
16func NewSetStatusOp(author bug.Person, status bug.Status) SetStatusOperation {
17 return SetStatusOperation{
18 OpBase: bug.NewOpBase(bug.SetStatusOp, author),
19 Status: status,
20 }
21}
22
23func (op SetStatusOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
24 snapshot.Status = op.Status
25
26 return snapshot
27}
28
29func Open(b *bug.Bug, author bug.Person) {
30 op := NewSetStatusOp(author, bug.OpenStatus)
31 b.Append(op)
32}
33
34func Close(b *bug.Bug, author bug.Person) {
35 op := NewSetStatusOp(author, bug.ClosedStatus)
36 b.Append(op)
37}