diff options
author | Michael Muré <batolettre@gmail.com> | 2018-08-02 23:37:49 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-08-02 23:37:49 +0200 |
commit | d8f89726fec3822d7d1dd42c52f478f37003b534 (patch) | |
tree | 567e97ee605ef3a286e42e11535fa6516321e743 /bug/operations/add_comment.go | |
parent | ed8f7eca9a8e0d1c448a7cc6240e2b7e357cf354 (diff) | |
download | git-bug-d8f89726fec3822d7d1dd42c52f478f37003b534.tar.gz |
implement media hosting in git for comments + API for the webui
Diffstat (limited to 'bug/operations/add_comment.go')
-rw-r--r-- | bug/operations/add_comment.go | 16 |
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) } |