aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operations
diff options
context:
space:
mode:
Diffstat (limited to 'bug/operations')
-rw-r--r--bug/operations/add_comment.go16
-rw-r--r--bug/operations/create.go15
-rw-r--r--bug/operations/label_change.go5
-rw-r--r--bug/operations/set_status.go5
-rw-r--r--bug/operations/set_title.go5
5 files changed, 42 insertions, 4 deletions
diff --git a/bug/operations/add_comment.go b/bug/operations/add_comment.go
index f35c572b..f2e76b73 100644
--- a/bug/operations/add_comment.go
+++ b/bug/operations/add_comment.go
@@ -2,6 +2,7 @@ package operations
import (
"github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/util"
)
// AddCommentOperation will add a new comment in the bug
@@ -11,12 +12,14 @@ var _ bug.Operation = AddCommentOperation{}
type AddCommentOperation struct {
bug.OpBase
Message string
+ files []util.Hash
}
func (op AddCommentOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
comment := bug.Comment{
Message: op.Message,
Author: op.Author,
+ Files: op.files,
UnixTime: op.UnixTime,
}
@@ -25,15 +28,24 @@ func (op AddCommentOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
return snapshot
}
-func NewAddCommentOp(author bug.Person, message string) AddCommentOperation {
+func (op AddCommentOperation) Files() []util.Hash {
+ return op.files
+}
+
+func NewAddCommentOp(author bug.Person, message string, files []util.Hash) AddCommentOperation {
return AddCommentOperation{
OpBase: bug.NewOpBase(bug.AddCommentOp, author),
Message: message,
+ files: files,
}
}
// Convenience function to apply the operation
func Comment(b *bug.Bug, author bug.Person, message string) {
- addCommentOp := NewAddCommentOp(author, message)
+ CommentWithFiles(b, author, message, nil)
+}
+
+func CommentWithFiles(b *bug.Bug, author bug.Person, message string, files []util.Hash) {
+ addCommentOp := NewAddCommentOp(author, message, files)
b.Append(addCommentOp)
}
diff --git a/bug/operations/create.go b/bug/operations/create.go
index 0ee7e857..ecbafb6f 100644
--- a/bug/operations/create.go
+++ b/bug/operations/create.go
@@ -2,6 +2,7 @@ package operations
import (
"github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/util"
)
// CreateOperation define the initial creation of a bug
@@ -12,6 +13,7 @@ type CreateOperation struct {
bug.OpBase
Title string
Message string
+ files []util.Hash
}
func (op CreateOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
@@ -28,18 +30,27 @@ func (op CreateOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
return snapshot
}
-func NewCreateOp(author bug.Person, title, message string) CreateOperation {
+func (op CreateOperation) Files() []util.Hash {
+ return op.files
+}
+
+func NewCreateOp(author bug.Person, title, message string, files []util.Hash) CreateOperation {
return CreateOperation{
OpBase: bug.NewOpBase(bug.CreateOp, author),
Title: title,
Message: message,
+ files: files,
}
}
// Convenience function to apply the operation
func Create(author bug.Person, title, message string) (*bug.Bug, error) {
+ return CreateWithFiles(author, title, message, nil)
+}
+
+func CreateWithFiles(author bug.Person, title, message string, files []util.Hash) (*bug.Bug, error) {
newBug := bug.NewBug()
- createOp := NewCreateOp(author, title, message)
+ createOp := NewCreateOp(author, title, message, files)
newBug.Append(createOp)
return newBug, nil
diff --git a/bug/operations/label_change.go b/bug/operations/label_change.go
index a711faef..f289fedc 100644
--- a/bug/operations/label_change.go
+++ b/bug/operations/label_change.go
@@ -3,6 +3,7 @@ package operations
import (
"fmt"
"github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/util"
"io"
"io/ioutil"
"sort"
@@ -50,6 +51,10 @@ AddLoop:
return snapshot
}
+func (op LabelChangeOperation) Files() []util.Hash {
+ return nil
+}
+
func NewLabelChangeOperation(author bug.Person, added, removed []bug.Label) LabelChangeOperation {
return LabelChangeOperation{
OpBase: bug.NewOpBase(bug.LabelChangeOp, author),
diff --git a/bug/operations/set_status.go b/bug/operations/set_status.go
index ed6c328c..87ca14bf 100644
--- a/bug/operations/set_status.go
+++ b/bug/operations/set_status.go
@@ -2,6 +2,7 @@ package operations
import (
"github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/util"
)
// SetStatusOperation will change the status of a bug
@@ -19,6 +20,10 @@ func (op SetStatusOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
return snapshot
}
+func (op SetStatusOperation) Files() []util.Hash {
+ return nil
+}
+
func NewSetStatusOp(author bug.Person, status bug.Status) SetStatusOperation {
return SetStatusOperation{
OpBase: bug.NewOpBase(bug.SetStatusOp, author),
diff --git a/bug/operations/set_title.go b/bug/operations/set_title.go
index fab01d8a..d6186f41 100644
--- a/bug/operations/set_title.go
+++ b/bug/operations/set_title.go
@@ -2,6 +2,7 @@ package operations
import (
"github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/util"
)
// SetTitleOperation will change the title of a bug
@@ -19,6 +20,10 @@ func (op SetTitleOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
return snapshot
}
+func (op SetTitleOperation) Files() []util.Hash {
+ return nil
+}
+
func NewSetTitleOp(author bug.Person, title string) SetTitleOperation {
return SetTitleOperation{
OpBase: bug.NewOpBase(bug.SetTitleOp, author),