From f7ea3421caa2c8957a82454255c4fdd699b70a9c Mon Sep 17 00:00:00 2001 From: Amine Hilaly Date: Sat, 4 May 2019 13:19:56 +0200 Subject: Add ForceLabelChange functionalities --- cache/bug_cache.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'cache/bug_cache.go') diff --git a/cache/bug_cache.go b/cache/bug_cache.go index 5fc76658..aad6dab8 100644 --- a/cache/bug_cache.go +++ b/cache/bug_cache.go @@ -139,6 +139,33 @@ func (c *BugCache) ChangeLabelsRaw(author *IdentityCache, unixTime int64, added return changes, op, nil } +func (c *BugCache) ForceChangeLabels(added []string, removed []string) (*bug.LabelChangeOperation, error) { + author, err := c.repoCache.GetUserIdentity() + if err != nil { + return nil, err + } + + return c.ForceChangeLabelsRaw(author, time.Now().Unix(), added, removed, nil) +} + +func (c *BugCache) ForceChangeLabelsRaw(author *IdentityCache, unixTime int64, added []string, removed []string, metadata map[string]string) (*bug.LabelChangeOperation, error) { + op, err := bug.ForceChangeLabels(c.bug, author.Identity, unixTime, added, removed) + if err != nil { + return nil, err + } + + for key, value := range metadata { + op.SetMetadata(key, value) + } + + err = c.notifyUpdated() + if err != nil { + return nil, err + } + + return op, nil +} + func (c *BugCache) Open() (*bug.SetStatusOperation, error) { author, err := c.repoCache.GetUserIdentity() if err != nil { -- cgit