diff options
author | Michael Muré <batolettre@gmail.com> | 2018-10-01 23:31:16 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-10-01 23:31:16 +0200 |
commit | 6ea6f3614e46a62f4a37c6afb488547a3d548191 (patch) | |
tree | 8a32431ce90dd8b169aac858b99a761b8f76c95f /cache/bug_cache.go | |
parent | f026f61aaaa7b9e579e99f171f7fefb38c4c6181 (diff) | |
download | git-bug-6ea6f3614e46a62f4a37c6afb488547a3d548191.tar.gz |
bug: in op convenience function, return the new op to be able to set metadata later
Diffstat (limited to 'cache/bug_cache.go')
-rw-r--r-- | cache/bug_cache.go | 68 |
1 files changed, 55 insertions, 13 deletions
diff --git a/cache/bug_cache.go b/cache/bug_cache.go index e7dd6178..b7c80a0c 100644 --- a/cache/bug_cache.go +++ b/cache/bug_cache.go @@ -49,11 +49,15 @@ func (c *BugCache) AddCommentWithFiles(message string, files []git.Hash) error { } func (c *BugCache) AddCommentRaw(author bug.Person, unixTime int64, message string, files []git.Hash, metadata map[string]string) error { - err := bug.AddCommentWithFiles(c.bug, author, unixTime, message, files) + op, err := bug.AddCommentWithFiles(c.bug, author, unixTime, message, files) if err != nil { return err } + for key, value := range metadata { + op.SetMetadata(key, value) + } + return c.notifyUpdated() } @@ -63,15 +67,19 @@ func (c *BugCache) ChangeLabels(added []string, removed []string) ([]bug.LabelCh return nil, err } - return c.ChangeLabelsRaw(author, time.Now().Unix(), added, removed) + return c.ChangeLabelsRaw(author, time.Now().Unix(), added, removed, nil) } -func (c *BugCache) ChangeLabelsRaw(author bug.Person, unixTime int64, added []string, removed []string) ([]bug.LabelChangeResult, error) { - changes, err := bug.ChangeLabels(c.bug, author, unixTime, added, removed) +func (c *BugCache) ChangeLabelsRaw(author bug.Person, unixTime int64, added []string, removed []string, metadata map[string]string) ([]bug.LabelChangeResult, error) { + changes, op, err := bug.ChangeLabels(c.bug, author, unixTime, added, removed) if err != nil { return changes, err } + for key, value := range metadata { + op.SetMetadata(key, value) + } + err = c.notifyUpdated() if err != nil { return nil, err @@ -86,15 +94,19 @@ func (c *BugCache) Open() error { return err } - return c.OpenRaw(author, time.Now().Unix()) + return c.OpenRaw(author, time.Now().Unix(), nil) } -func (c *BugCache) OpenRaw(author bug.Person, unixTime int64) error { - err := bug.Open(c.bug, author, unixTime) +func (c *BugCache) OpenRaw(author bug.Person, unixTime int64, metadata map[string]string) error { + op, err := bug.Open(c.bug, author, unixTime) if err != nil { return err } + for key, value := range metadata { + op.SetMetadata(key, value) + } + return c.notifyUpdated() } @@ -104,15 +116,19 @@ func (c *BugCache) Close() error { return err } - return c.CloseRaw(author, time.Now().Unix()) + return c.CloseRaw(author, time.Now().Unix(), nil) } -func (c *BugCache) CloseRaw(author bug.Person, unixTime int64) error { - err := bug.Close(c.bug, author, unixTime) +func (c *BugCache) CloseRaw(author bug.Person, unixTime int64, metadata map[string]string) error { + op, err := bug.Close(c.bug, author, unixTime) if err != nil { return err } + for key, value := range metadata { + op.SetMetadata(key, value) + } + return c.notifyUpdated() } @@ -122,15 +138,41 @@ func (c *BugCache) SetTitle(title string) error { return err } - return c.SetTitleRaw(author, time.Now().Unix(), title) + return c.SetTitleRaw(author, time.Now().Unix(), title, nil) +} + +func (c *BugCache) SetTitleRaw(author bug.Person, unixTime int64, title string, metadata map[string]string) error { + op, err := bug.SetTitle(c.bug, author, unixTime, title) + if err != nil { + return err + } + + for key, value := range metadata { + op.SetMetadata(key, value) + } + + return c.notifyUpdated() +} + +func (c *BugCache) EditComment(target git.Hash, message string) error { + author, err := bug.GetUser(c.repoCache.repo) + if err != nil { + return err + } + + return c.EditCommentRaw(author, time.Now().Unix(), target, message, nil) } -func (c *BugCache) SetTitleRaw(author bug.Person, unixTime int64, title string) error { - err := bug.SetTitle(c.bug, author, unixTime, title) +func (c *BugCache) EditCommentRaw(author bug.Person, unixTime int64, target git.Hash, message string, metadata map[string]string) error { + op, err := bug.EditComment(c.bug, author, unixTime, target, message) if err != nil { return err } + for key, value := range metadata { + op.SetMetadata(key, value) + } + return c.notifyUpdated() } |