diff options
author | Michael Muré <batolettre@gmail.com> | 2022-07-31 14:38:32 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-07-31 14:38:32 +0200 |
commit | d179b8b7ec7815ccac73e00f35f5cfbdc4ddbe2e (patch) | |
tree | d3faa7217cb287c7b20f2769f5c5808373aca63b /bug/op_edit_comment.go | |
parent | 3d454d9dc8ba2409046c0938618a70864e6eb8ef (diff) | |
download | git-bug-d179b8b7ec7815ccac73e00f35f5cfbdc4ddbe2e.tar.gz |
bug: fix an issue where Id would be used, then changed due to metadata
Diffstat (limited to 'bug/op_edit_comment.go')
-rw-r--r-- | bug/op_edit_comment.go | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/bug/op_edit_comment.go b/bug/op_edit_comment.go index 36c31663..70a362de 100644 --- a/bug/op_edit_comment.go +++ b/bug/op_edit_comment.go @@ -110,27 +110,20 @@ func NewEditCommentOp(author identity.Interface, unixTime int64, target entity.I } // EditComment is a convenience function to apply the operation -func EditComment(b Interface, author identity.Interface, unixTime int64, target entity.Id, message string) (*EditCommentOperation, error) { - return EditCommentWithFiles(b, author, unixTime, target, message, nil) -} - -func EditCommentWithFiles(b Interface, author identity.Interface, unixTime int64, target entity.Id, message string, files []repository.Hash) (*EditCommentOperation, error) { - editCommentOp := NewEditCommentOp(author, unixTime, target, message, files) - if err := editCommentOp.Validate(); err != nil { +func EditComment(b Interface, author identity.Interface, unixTime int64, target entity.Id, message string, files []repository.Hash, metadata map[string]string) (*EditCommentOperation, error) { + op := NewEditCommentOp(author, unixTime, target, message, files) + for key, val := range metadata { + op.SetMetadata(key, val) + } + if err := op.Validate(); err != nil { return nil, err } - b.Append(editCommentOp) - return editCommentOp, nil + b.Append(op) + return op, nil } // EditCreateComment is a convenience function to edit the body of a bug (the first comment) -func EditCreateComment(b Interface, author identity.Interface, unixTime int64, message string) (*EditCommentOperation, error) { - createOp := b.FirstOp().(*CreateOperation) - return EditComment(b, author, unixTime, createOp.Id(), message) -} - -// EditCreateCommentWithFiles is a convenience function to edit the body of a bug (the first comment) -func EditCreateCommentWithFiles(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash) (*EditCommentOperation, error) { +func EditCreateComment(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash, metadata map[string]string) (*EditCommentOperation, error) { createOp := b.FirstOp().(*CreateOperation) - return EditCommentWithFiles(b, author, unixTime, createOp.Id(), message, files) + return EditComment(b, author, unixTime, createOp.Id(), message, files, metadata) } |