diff options
author | Michael Muré <batolettre@gmail.com> | 2021-04-04 15:49:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-04 15:49:16 +0200 |
commit | fc04af34f5d6dff930003cc1f27ead972d424324 (patch) | |
tree | 8b9750d46182fff88d72fcc891e89d5a79ed83b0 /bug/op_add_comment.go | |
parent | 2055bd5d0afb534cc98cd11bd9802d66acbb0c8f (diff) | |
parent | cb9b06551ddc1fae33046733f79ede20f8d09f9a (diff) | |
download | git-bug-fc04af34f5d6dff930003cc1f27ead972d424324.tar.gz |
Merge pull request #532 from MichaelMure/dag-entity
Work towards a reusable entity datastructure + commit signature
Diffstat (limited to 'bug/op_add_comment.go')
-rw-r--r-- | bug/op_add_comment.go | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/bug/op_add_comment.go b/bug/op_add_comment.go index 3f19e42e..f835866b 100644 --- a/bug/op_add_comment.go +++ b/bug/op_add_comment.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/MichaelMure/git-bug/entity" + "github.com/MichaelMure/git-bug/entity/dag" "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/repository" "github.com/MichaelMure/git-bug/util/text" @@ -12,6 +13,7 @@ import ( ) var _ Operation = &AddCommentOperation{} +var _ dag.OperationWithFiles = &AddCommentOperation{} // AddCommentOperation will add a new comment in the bug type AddCommentOperation struct { @@ -21,25 +23,19 @@ type AddCommentOperation struct { Files []repository.Hash `json:"files"` } -// Sign-post method for gqlgen -func (op *AddCommentOperation) IsOperation() {} - -func (op *AddCommentOperation) base() *OpBase { - return &op.OpBase -} - func (op *AddCommentOperation) Id() entity.Id { - return idOperation(op) + return idOperation(op, &op.OpBase) } func (op *AddCommentOperation) Apply(snapshot *Snapshot) { - snapshot.addActor(op.Author) - snapshot.addParticipant(op.Author) + snapshot.addActor(op.Author_) + snapshot.addParticipant(op.Author_) + commentId := entity.CombineIds(snapshot.Id(), op.Id()) comment := Comment{ - id: op.Id(), + id: commentId, Message: op.Message, - Author: op.Author, + Author: op.Author_, Files: op.Files, UnixTime: timestamp.Timestamp(op.UnixTime), } @@ -47,7 +43,7 @@ func (op *AddCommentOperation) Apply(snapshot *Snapshot) { snapshot.Comments = append(snapshot.Comments, comment) item := &AddCommentTimelineItem{ - CommentTimelineItem: NewCommentTimelineItem(op.Id(), comment), + CommentTimelineItem: NewCommentTimelineItem(commentId, comment), } snapshot.Timeline = append(snapshot.Timeline, item) @@ -58,7 +54,7 @@ func (op *AddCommentOperation) GetFiles() []repository.Hash { } func (op *AddCommentOperation) Validate() error { - if err := opBaseValidate(op, AddCommentOp); err != nil { + if err := op.OpBase.Validate(op, AddCommentOp); err != nil { return err } |