aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operations
diff options
context:
space:
mode:
Diffstat (limited to 'bug/operations')
-rw-r--r--bug/operations/add_comment.go15
-rw-r--r--bug/operations/create.go13
-rw-r--r--bug/operations/create_test.go2
-rw-r--r--bug/operations/set_status.go9
-rw-r--r--bug/operations/set_title.go11
5 files changed, 25 insertions, 25 deletions
diff --git a/bug/operations/add_comment.go b/bug/operations/add_comment.go
index 2927295a..9ee8dc64 100644
--- a/bug/operations/add_comment.go
+++ b/bug/operations/add_comment.go
@@ -2,32 +2,29 @@ package operations
import (
"github.com/MichaelMure/git-bug/bug"
- "time"
)
+// AddCommentOperation will add a new comment in the bug
+
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},
+ OpBase: bug.NewOpBase(bug.AddCommentOp, author),
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,
+ Message: op.Message,
+ Author: op.Author,
+ UnixTime: op.UnixTime,
}
snapshot.Comments = append(snapshot.Comments, comment)
diff --git a/bug/operations/create.go b/bug/operations/create.go
index ad1d99ac..72eba843 100644
--- a/bug/operations/create.go
+++ b/bug/operations/create.go
@@ -2,7 +2,6 @@ package operations
import (
"github.com/MichaelMure/git-bug/bug"
- "time"
)
// CreateOperation define the initial creation of a bug
@@ -13,17 +12,13 @@ type CreateOperation struct {
bug.OpBase
Title string
Message string
- Author bug.Person
- Time int64
}
func NewCreateOp(author bug.Person, title, message string) CreateOperation {
return CreateOperation{
- OpBase: bug.OpBase{OperationType: bug.CreateOp},
+ OpBase: bug.NewOpBase(bug.CreateOp, author),
Title: title,
Message: message,
- Author: author,
- Time: time.Now().Unix(),
}
}
@@ -31,9 +26,9 @@ func (op CreateOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
snapshot.Title = op.Title
snapshot.Comments = []bug.Comment{
{
- Message: op.Message,
- Author: op.Author,
- Time: op.Time,
+ Message: op.Message,
+ Author: op.Author,
+ UnixTime: op.UnixTime,
},
}
return snapshot
diff --git a/bug/operations/create_test.go b/bug/operations/create_test.go
index c262a41c..8aade05f 100644
--- a/bug/operations/create_test.go
+++ b/bug/operations/create_test.go
@@ -21,7 +21,7 @@ func TestCreate(t *testing.T) {
expected := bug.Snapshot{
Title: "title",
Comments: []bug.Comment{
- {Author: rene, Message: "message", Time: create.Time},
+ {Author: rene, Message: "message", UnixTime: create.UnixTime},
},
}
diff --git a/bug/operations/set_status.go b/bug/operations/set_status.go
index aa673bb1..7c718cd6 100644
--- a/bug/operations/set_status.go
+++ b/bug/operations/set_status.go
@@ -1,6 +1,8 @@
package operations
-import "github.com/MichaelMure/git-bug/bug"
+import (
+ "github.com/MichaelMure/git-bug/bug"
+)
// SetStatusOperation will change the status of a bug
@@ -11,14 +13,15 @@ type SetStatusOperation struct {
Status bug.Status
}
-func NewSetStatusOp(status bug.Status) SetStatusOperation {
+func NewSetStatusOp(author bug.Person, status bug.Status) SetStatusOperation {
return SetStatusOperation{
- OpBase: bug.OpBase{OperationType: bug.SetStatusOp},
+ OpBase: bug.NewOpBase(bug.SetStatusOp, author),
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 c5e0ab0e..ef934db1 100644
--- a/bug/operations/set_title.go
+++ b/bug/operations/set_title.go
@@ -1,6 +1,10 @@
package operations
-import "github.com/MichaelMure/git-bug/bug"
+import (
+ "github.com/MichaelMure/git-bug/bug"
+)
+
+// SetTitleOperation will change the title of a bug
var _ bug.Operation = SetTitleOperation{}
@@ -9,14 +13,15 @@ type SetTitleOperation struct {
Title string
}
-func NewSetTitleOp(title string) SetTitleOperation {
+func NewSetTitleOp(author bug.Person, title string) SetTitleOperation {
return SetTitleOperation{
- OpBase: bug.OpBase{OperationType: bug.SetTitleOp},
+ OpBase: bug.NewOpBase(bug.SetTitleOp, author),
Title: title,
}
}
func (op SetTitleOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
snapshot.Title = op.Title
+
return snapshot
}