diff options
author | Michael Muré <batolettre@gmail.com> | 2022-08-23 15:01:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 15:01:36 +0200 |
commit | 5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f (patch) | |
tree | e5382a09a45098672b6d60397eac201617fdd6ec /entities/bug/snapshot.go | |
parent | 81fd7a5d8b6443e65c861f00a7387c0a3c926c66 (diff) | |
parent | 6ed4b8b7a1185ad278eb2e40b32e859f828233d9 (diff) | |
download | git-bug-5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f.tar.gz |
Merge pull request #664 from MichaelMure/combined-id-rework
bug: have a type for combined ids, fix #653
Diffstat (limited to 'entities/bug/snapshot.go')
-rw-r--r-- | entities/bug/snapshot.go | 23 |
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 |