aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operations/add_comment.go
diff options
context:
space:
mode:
Diffstat (limited to 'bug/operations/add_comment.go')
-rw-r--r--bug/operations/add_comment.go16
1 files changed, 14 insertions, 2 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)
}