aboutsummaryrefslogtreecommitdiffstats
path: root/cache/repo_cache.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-25 17:56:58 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-25 17:56:58 +0200
commit40c6e64e4badfd543dc98237e1aeb3d8958cfe90 (patch)
tree03a992d71a1bfa3f069a5ef179649c0cf8479764 /cache/repo_cache.go
parent5d7c3a76af85a857a6bb0bff5bac5282c0a9908f (diff)
downloadgit-bug-40c6e64e4badfd543dc98237e1aeb3d8958cfe90.tar.gz
cache: add raw edit functions to allow setting up the author, the timestamp and the metadatas
Diffstat (limited to 'cache/repo_cache.go')
-rw-r--r--cache/repo_cache.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index 4ca19150..2278b604 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -11,6 +11,7 @@ import (
"sort"
"strconv"
"strings"
+ "time"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/operations"
@@ -354,11 +355,22 @@ func (c *RepoCache) NewBugWithFiles(title string, message string, files []git.Ha
return nil, err
}
- b, err := operations.CreateWithFiles(author, title, message, files)
+ return c.NewBugRaw(author, time.Now().Unix(), title, message, files, nil)
+}
+
+// NewBugWithFilesMeta create a new bug with attached files for the message, as
+// well as metadata for the Create operation.
+// The new bug is written in the repository (commit)
+func (c *RepoCache) NewBugRaw(author bug.Person, unixTime int64, title string, message string, files []git.Hash, metadata map[string]string) (*BugCache, error) {
+ b, err := operations.CreateWithFiles(author, unixTime, title, message, files)
if err != nil {
return nil, err
}
+ for key, value := range metadata {
+ b.FirstOp().SetMetadata(key, value)
+ }
+
err = b.Commit(c.repo)
if err != nil {
return nil, err