aboutsummaryrefslogtreecommitdiffstats
path: root/entities
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-11-13 12:31:38 +0100
committerMichael Muré <batolettre@gmail.com>2022-11-13 12:31:38 +0100
commit3c6ebc2bfd50b72ff786a2cfd3bbdeb15b478dd3 (patch)
tree8cf4307bf48f016e0f8728c311bcc53ce38432e3 /entities
parent55a2e8e4485fe63fbda759540958c7190dfeb85c (diff)
downloadgit-bug-3c6ebc2bfd50b72ff786a2cfd3bbdeb15b478dd3.tar.gz
core: bubble up the comment ID when created, or edited the first comment
Diffstat (limited to 'entities')
-rw-r--r--entities/bug/op_add_comment.go6
-rw-r--r--entities/bug/op_edit_comment.go8
-rw-r--r--entities/bug/op_label_change.go1
-rw-r--r--entities/bug/op_set_status.go1
-rw-r--r--entities/bug/op_set_title.go6
5 files changed, 7 insertions, 15 deletions
diff --git a/entities/bug/op_add_comment.go b/entities/bug/op_add_comment.go
index b049ef16..5edef9d0 100644
--- a/entities/bug/op_add_comment.go
+++ b/entities/bug/op_add_comment.go
@@ -83,14 +83,14 @@ type AddCommentTimelineItem struct {
func (a *AddCommentTimelineItem) IsAuthored() {}
// AddComment is a convenience function to add a comment to a bug
-func AddComment(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash, metadata map[string]string) (*AddCommentOperation, error) {
+func AddComment(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash, metadata map[string]string) (entity.CombinedId, *AddCommentOperation, error) {
op := NewAddCommentOp(author, unixTime, message, files)
for key, val := range metadata {
op.SetMetadata(key, val)
}
if err := op.Validate(); err != nil {
- return nil, err
+ return entity.UnsetCombinedId, nil, err
}
b.Append(op)
- return op, nil
+ return entity.CombineIds(b.Id(), op.Id()), op, nil
}
diff --git a/entities/bug/op_edit_comment.go b/entities/bug/op_edit_comment.go
index b0897b0a..6ac09fd7 100644
--- a/entities/bug/op_edit_comment.go
+++ b/entities/bug/op_edit_comment.go
@@ -111,20 +111,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, files []repository.Hash, metadata map[string]string) (*EditCommentOperation, error) {
+func EditComment(b Interface, author identity.Interface, unixTime int64, target entity.Id, message string, files []repository.Hash, metadata map[string]string) (entity.CombinedId, *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
+ return entity.UnsetCombinedId, nil, err
}
b.Append(op)
- return op, nil
+ return entity.CombineIds(b.Id(), target), 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, files []repository.Hash, metadata map[string]string) (*EditCommentOperation, error) {
+func EditCreateComment(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash, metadata map[string]string) (entity.CombinedId, *EditCommentOperation, error) {
createOp := b.FirstOp().(*CreateOperation)
return EditComment(b, author, unixTime, createOp.Id(), message, files, metadata)
}
diff --git a/entities/bug/op_label_change.go b/entities/bug/op_label_change.go
index 76b2ebef..0d13fe9e 100644
--- a/entities/bug/op_label_change.go
+++ b/entities/bug/op_label_change.go
@@ -105,7 +105,6 @@ func NewLabelChangeOperation(author identity.Interface, unixTime int64, added, r
}
type LabelChangeTimelineItem struct {
- // id entity.Id
combinedId entity.CombinedId
Author identity.Interface
UnixTime timestamp.Timestamp
diff --git a/entities/bug/op_set_status.go b/entities/bug/op_set_status.go
index 23be59a0..68199129 100644
--- a/entities/bug/op_set_status.go
+++ b/entities/bug/op_set_status.go
@@ -58,7 +58,6 @@ func NewSetStatusOp(author identity.Interface, unixTime int64, status common.Sta
}
type SetStatusTimelineItem struct {
- // id entity.Id
combinedId entity.CombinedId
Author identity.Interface
UnixTime timestamp.Timestamp
diff --git a/entities/bug/op_set_title.go b/entities/bug/op_set_title.go
index e9526b64..6e445aa6 100644
--- a/entities/bug/op_set_title.go
+++ b/entities/bug/op_set_title.go
@@ -30,7 +30,6 @@ func (op *SetTitleOperation) Apply(snapshot *Snapshot) {
id := op.Id()
item := &SetTitleTimelineItem{
- id: id,
combinedId: entity.CombineIds(snapshot.Id(), id),
Author: op.Author(),
UnixTime: timestamp.Timestamp(op.UnixTime),
@@ -70,7 +69,6 @@ func NewSetTitleOp(author identity.Interface, unixTime int64, title string, was
}
type SetTitleTimelineItem struct {
- id entity.Id
combinedId entity.CombinedId
Author identity.Interface
UnixTime timestamp.Timestamp
@@ -78,10 +76,6 @@ type SetTitleTimelineItem struct {
Was string
}
-func (s SetTitleTimelineItem) Id() entity.Id {
- return s.id
-}
-
func (s SetTitleTimelineItem) CombinedId() entity.CombinedId {
return s.combinedId
}