aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operations
diff options
context:
space:
mode:
Diffstat (limited to 'bug/operations')
-rw-r--r--bug/operations/add_comment.go2
-rw-r--r--bug/operations/create.go9
-rw-r--r--bug/operations/operations.go1
-rw-r--r--bug/operations/set_status.go24
-rw-r--r--bug/operations/set_title.go2
5 files changed, 28 insertions, 10 deletions
diff --git a/bug/operations/add_comment.go b/bug/operations/add_comment.go
index ce33522c..2927295a 100644
--- a/bug/operations/add_comment.go
+++ b/bug/operations/add_comment.go
@@ -16,7 +16,7 @@ type AddCommentOperation struct {
func NewAddCommentOp(author bug.Person, message string) AddCommentOperation {
return AddCommentOperation{
- OpBase: bug.OpBase{OperationType: bug.ADD_COMMENT},
+ OpBase: bug.OpBase{OperationType: bug.AddCommentOp},
Message: message,
Author: author,
Time: time.Now().Unix(),
diff --git a/bug/operations/create.go b/bug/operations/create.go
index f4ca11ad..ad1d99ac 100644
--- a/bug/operations/create.go
+++ b/bug/operations/create.go
@@ -2,7 +2,6 @@ package operations
import (
"github.com/MichaelMure/git-bug/bug"
- "reflect"
"time"
)
@@ -20,7 +19,7 @@ type CreateOperation struct {
func NewCreateOp(author bug.Person, title, message string) CreateOperation {
return CreateOperation{
- OpBase: bug.OpBase{OperationType: bug.CREATE},
+ OpBase: bug.OpBase{OperationType: bug.CreateOp},
Title: title,
Message: message,
Author: author,
@@ -29,12 +28,6 @@ func NewCreateOp(author bug.Person, title, message string) CreateOperation {
}
func (op CreateOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
- empty := bug.Snapshot{}
-
- if !reflect.DeepEqual(snapshot, empty) {
- panic("Create operation should never be applied on a non-empty snapshot")
- }
-
snapshot.Title = op.Title
snapshot.Comments = []bug.Comment{
{
diff --git a/bug/operations/operations.go b/bug/operations/operations.go
index f42d6e9a..50692952 100644
--- a/bug/operations/operations.go
+++ b/bug/operations/operations.go
@@ -7,4 +7,5 @@ func init() {
gob.Register(AddCommentOperation{})
gob.Register(CreateOperation{})
gob.Register(SetTitleOperation{})
+ gob.Register(SetStatusOperation{})
}
diff --git a/bug/operations/set_status.go b/bug/operations/set_status.go
new file mode 100644
index 00000000..aa673bb1
--- /dev/null
+++ b/bug/operations/set_status.go
@@ -0,0 +1,24 @@
+package operations
+
+import "github.com/MichaelMure/git-bug/bug"
+
+// SetStatusOperation will change the status of a bug
+
+var _ bug.Operation = SetStatusOperation{}
+
+type SetStatusOperation struct {
+ bug.OpBase
+ Status bug.Status
+}
+
+func NewSetStatusOp(status bug.Status) SetStatusOperation {
+ return SetStatusOperation{
+ OpBase: bug.OpBase{OperationType: bug.SetStatusOp},
+ Status: status,
+ }
+}
+
+func (op SetStatusOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
+ snapshot.Status = op.Status
+ return snapshot
+}
diff --git a/bug/operations/set_title.go b/bug/operations/set_title.go
index 6d5cb87f..c5e0ab0e 100644
--- a/bug/operations/set_title.go
+++ b/bug/operations/set_title.go
@@ -11,7 +11,7 @@ type SetTitleOperation struct {
func NewSetTitleOp(title string) SetTitleOperation {
return SetTitleOperation{
- OpBase: bug.OpBase{OperationType: bug.SET_TITLE},
+ OpBase: bug.OpBase{OperationType: bug.SetTitleOp},
Title: title,
}
}