From 45b04351d8d02e53b3401b0ee23f7cbe750b63cd Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Mon, 3 May 2021 11:45:15 +0200 Subject: bug: have a type for combined ids, fix https://github.com/MichaelMure/git-bug/issues/653 --- entities/bug/op_label_change.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'entities/bug/op_label_change.go') diff --git a/entities/bug/op_label_change.go b/entities/bug/op_label_change.go index 45441f7c..76b2ebef 100644 --- a/entities/bug/op_label_change.go +++ b/entities/bug/op_label_change.go @@ -59,12 +59,14 @@ AddLoop: return string(snapshot.Labels[i]) < string(snapshot.Labels[j]) }) + id := op.Id() item := &LabelChangeTimelineItem{ - id: op.Id(), - Author: op.Author(), - UnixTime: timestamp.Timestamp(op.UnixTime), - Added: op.Added, - Removed: op.Removed, + // id: id, + combinedId: entity.CombineIds(snapshot.Id(), id), + Author: op.Author(), + UnixTime: timestamp.Timestamp(op.UnixTime), + Added: op.Added, + Removed: op.Removed, } snapshot.Timeline = append(snapshot.Timeline, item) @@ -103,19 +105,20 @@ func NewLabelChangeOperation(author identity.Interface, unixTime int64, added, r } type LabelChangeTimelineItem struct { - id entity.Id - Author identity.Interface - UnixTime timestamp.Timestamp - Added []Label - Removed []Label + // id entity.Id + combinedId entity.CombinedId + Author identity.Interface + UnixTime timestamp.Timestamp + Added []Label + Removed []Label } -func (l LabelChangeTimelineItem) Id() entity.Id { - return l.id +func (l LabelChangeTimelineItem) CombinedId() entity.CombinedId { + return l.combinedId } // IsAuthored is a sign post method for gqlgen -func (l LabelChangeTimelineItem) IsAuthored() {} +func (l *LabelChangeTimelineItem) IsAuthored() {} // ChangeLabels is a convenience function to change labels on a bug func ChangeLabels(b Interface, author identity.Interface, unixTime int64, add, remove []string, metadata map[string]string) ([]LabelChangeResult, *LabelChangeOperation, error) { @@ -180,7 +183,7 @@ func ChangeLabels(b Interface, author identity.Interface, unixTime int64, add, r } // ForceChangeLabels is a convenience function to apply the operation -// The difference with ChangeLabels is that no checks of deduplications are done. You are entirely +// The difference with ChangeLabels is that no checks for deduplication are done. You are entirely // responsible for what you are doing. In the general case, you want to use ChangeLabels instead. // The intended use of this function is to allow importers to create legal but unexpected label changes, // like removing a label with no information of when it was added before. -- cgit