aboutsummaryrefslogtreecommitdiffstats
path: root/entities/bug/snapshot.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-05-03 11:45:15 +0200
committerMichael Muré <batolettre@gmail.com>2022-08-22 13:25:26 +0200
commit45b04351d8d02e53b3401b0ee23f7cbe750b63cd (patch)
tree59d203ef6c0f6a497b7074cd5617c8869cac3b14 /entities/bug/snapshot.go
parent43026fc53669d462a60feec7d22aec090959be72 (diff)
downloadgit-bug-45b04351d8d02e53b3401b0ee23f7cbe750b63cd.tar.gz
bug: have a type for combined ids, fix https://github.com/MichaelMure/git-bug/issues/653
Diffstat (limited to 'entities/bug/snapshot.go')
-rw-r--r--entities/bug/snapshot.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/entities/bug/snapshot.go b/entities/bug/snapshot.go
index 442496f7..333fe207 100644
--- a/entities/bug/snapshot.go
+++ b/entities/bug/snapshot.go
@@ -58,9 +58,9 @@ func (snap *Snapshot) GetCreateMetadata(key string) (string, bool) {
}
// SearchTimelineItem will search in the timeline for an item matching the given hash
-func (snap *Snapshot) SearchTimelineItem(id entity.Id) (TimelineItem, error) {
+func (snap *Snapshot) SearchTimelineItem(id entity.CombinedId) (TimelineItem, error) {
for i := range snap.Timeline {
- if snap.Timeline[i].Id() == id {
+ if snap.Timeline[i].CombinedId() == id {
return snap.Timeline[i], nil
}
}
@@ -68,15 +68,26 @@ func (snap *Snapshot) SearchTimelineItem(id entity.Id) (TimelineItem, error) {
return nil, fmt.Errorf("timeline item not found")
}
-// SearchComment will search for a comment matching the given hash
-func (snap *Snapshot) SearchComment(id entity.Id) (*Comment, error) {
+// SearchComment will search for a comment matching the given id
+func (snap *Snapshot) SearchComment(id entity.CombinedId) (*Comment, error) {
for _, c := range snap.Comments {
- if c.id == id {
+ if c.combinedId == id {
return &c, nil
}
}
- return nil, fmt.Errorf("comment item not found")
+ return nil, fmt.Errorf("comment not found")
+}
+
+// SearchCommentByOpId will search for a comment generated by the given operation Id
+func (snap *Snapshot) SearchCommentByOpId(id entity.Id) (*Comment, error) {
+ for _, c := range snap.Comments {
+ if c.targetId == id {
+ return &c, nil
+ }
+ }
+
+ return nil, fmt.Errorf("comment not found")
}
// append the operation author to the actors list