aboutsummaryrefslogtreecommitdiffstats
path: root/cache/bug_cache.go
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-05-04 13:19:56 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-05-05 18:16:10 +0200
commitf7ea3421caa2c8957a82454255c4fdd699b70a9c (patch)
tree299faef7b4588dd5f39b0908ee3c5668655926a6 /cache/bug_cache.go
parent0d976f66e87b7c053b10d50fe0849f6c8e5412e6 (diff)
downloadgit-bug-f7ea3421caa2c8957a82454255c4fdd699b70a9c.tar.gz
Add ForceLabelChange functionalities
Diffstat (limited to 'cache/bug_cache.go')
-rw-r--r--cache/bug_cache.go27
1 files changed, 27 insertions, 0 deletions
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 {