aboutsummaryrefslogtreecommitdiffstats
path: root/bug/op_label_change.go
diff options
context:
space:
mode:
Diffstat (limited to 'bug/op_label_change.go')
-rw-r--r--bug/op_label_change.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/bug/op_label_change.go b/bug/op_label_change.go
index a2108941..0e7929b7 100644
--- a/bug/op_label_change.go
+++ b/bug/op_label_change.go
@@ -234,6 +234,33 @@ func ChangeLabels(b Interface, author identity.Interface, unixTime int64, add, r
return results, labelOp, nil
}
+// ForceChangeLabels is a convenience function to apply the operation
+// The difference with ChangeLabels is that no checks of deduplications are done. You are entirely
+// responsible of 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.
+func ForceChangeLabels(b Interface, author identity.Interface, unixTime int64, add, remove []string) (*LabelChangeOperation, error) {
+ added := make([]Label, len(add))
+ for i, str := range add {
+ added[i] = Label(str)
+ }
+
+ removed := make([]Label, len(remove))
+ for i, str := range remove {
+ removed[i] = Label(str)
+ }
+
+ labelOp := NewLabelChangeOperation(author, unixTime, added, removed)
+
+ if err := labelOp.Validate(); err != nil {
+ return nil, err
+ }
+
+ b.Append(labelOp)
+
+ return labelOp, nil
+}
+
func labelExist(labels []Label, label Label) bool {
for _, l := range labels {
if l == label {