diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-13 22:53:53 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-13 22:53:53 +0200 |
commit | 55aef8c38773a7cce39a5e154f8221a4b817ac04 (patch) | |
tree | 6fb23c7f099a69c9abfdca7f05fee108f3ec6786 /bug/operations/add_comment.go | |
parent | 35d64e4f9e3e0a0ffd041e430a64650bb8ea71fa (diff) | |
download | git-bug-55aef8c38773a7cce39a5e154f8221a4b817ac04.tar.gz |
implement AddComment
Diffstat (limited to 'bug/operations/add_comment.go')
-rw-r--r-- | bug/operations/add_comment.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bug/operations/add_comment.go b/bug/operations/add_comment.go new file mode 100644 index 00000000..2b83de83 --- /dev/null +++ b/bug/operations/add_comment.go @@ -0,0 +1,30 @@ +package operations + +import "github.com/MichaelMure/git-bug/bug" + +var _ bug.Operation = AddCommentOperation{} + +type AddCommentOperation struct { + bug.OpBase + Message string `json:"m"` + Author bug.Person `json:"a"` +} + +func NewAddCommentOp(author bug.Person, message string) AddCommentOperation { + return AddCommentOperation{ + OpBase: bug.OpBase{OperationType: bug.ADD_COMMENT}, + Message: message, + Author: author, + } +} + +func (op AddCommentOperation) Apply(snapshot bug.Snapshot) bug.Snapshot { + comment := bug.Comment{ + Message: op.Message, + Author: op.Author, + } + + snapshot.Comments = append(snapshot.Comments, comment) + + return snapshot +} |