diff options
author | Michael Muré <batolettre@gmail.com> | 2019-05-06 00:14:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-06 00:14:14 +0200 |
commit | 33c1c79a55f04689c45385c4ccf74da462532011 (patch) | |
tree | 7c4bfd33ae24f272df045583c4ace761c8dd4242 /bug | |
parent | c0c8b11549930210688a06c64b3cc68d2159a0e8 (diff) | |
parent | 2e17f371758ad25a3674d65ef0e8e32a4660e6d4 (diff) | |
download | git-bug-33c1c79a55f04689c45385c4ccf74da462532011.tar.gz |
Merge pull request #131 from A-Hilaly/github-import
github: support for partial import and refactor into iterator/importer
Diffstat (limited to 'bug')
-rw-r--r-- | bug/op_label_change.go | 27 |
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 { |