diff options
author | Michael Muré <michael.mure@consensys.net> | 2018-11-21 18:56:12 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-03-01 22:35:36 +0100 |
commit | feab9412dffe5772048aad29893c4cb01d566387 (patch) | |
tree | b7bc9751f2ebdf8d41f5621bbf372eaf7625c4b9 /cache | |
parent | 0aefae6fcca5786f2c898029c3d6282f760f2c63 (diff) | |
download | git-bug-feab9412dffe5772048aad29893c4cb01d566387.tar.gz |
WIP identity in git
Diffstat (limited to 'cache')
-rw-r--r-- | cache/bug_cache.go | 26 | ||||
-rw-r--r-- | cache/bug_excerpt.go | 4 | ||||
-rw-r--r-- | cache/repo_cache.go | 5 |
3 files changed, 20 insertions, 15 deletions
diff --git a/cache/bug_cache.go b/cache/bug_cache.go index 52e9eafb..25ff000c 100644 --- a/cache/bug_cache.go +++ b/cache/bug_cache.go @@ -5,6 +5,8 @@ import ( "strings" "time" + "github.com/MichaelMure/git-bug/identity" + "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/util/git" ) @@ -87,7 +89,7 @@ func (c *BugCache) AddComment(message string) error { } func (c *BugCache) AddCommentWithFiles(message string, files []git.Hash) error { - author, err := bug.GetUser(c.repoCache.repo) + author, err := identity.GetIdentity(c.repoCache.repo) if err != nil { return err } @@ -95,7 +97,7 @@ func (c *BugCache) AddCommentWithFiles(message string, files []git.Hash) error { return c.AddCommentRaw(author, time.Now().Unix(), message, files, nil) } -func (c *BugCache) AddCommentRaw(author bug.Person, unixTime int64, message string, files []git.Hash, metadata map[string]string) error { +func (c *BugCache) AddCommentRaw(author *identity.Identity, unixTime int64, message string, files []git.Hash, metadata map[string]string) error { op, err := bug.AddCommentWithFiles(c.bug, author, unixTime, message, files) if err != nil { return err @@ -109,7 +111,7 @@ func (c *BugCache) AddCommentRaw(author bug.Person, unixTime int64, message stri } func (c *BugCache) ChangeLabels(added []string, removed []string) ([]bug.LabelChangeResult, error) { - author, err := bug.GetUser(c.repoCache.repo) + author, err := identity.GetIdentity(c.repoCache.repo) if err != nil { return nil, err } @@ -117,7 +119,7 @@ func (c *BugCache) ChangeLabels(added []string, removed []string) ([]bug.LabelCh return c.ChangeLabelsRaw(author, time.Now().Unix(), added, removed, nil) } -func (c *BugCache) ChangeLabelsRaw(author bug.Person, unixTime int64, added []string, removed []string, metadata map[string]string) ([]bug.LabelChangeResult, error) { +func (c *BugCache) ChangeLabelsRaw(author *identity.Identity, 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 @@ -136,7 +138,7 @@ func (c *BugCache) ChangeLabelsRaw(author bug.Person, unixTime int64, added []st } func (c *BugCache) Open() error { - author, err := bug.GetUser(c.repoCache.repo) + author, err := identity.GetIdentity(c.repoCache.repo) if err != nil { return err } @@ -144,7 +146,7 @@ func (c *BugCache) Open() error { return c.OpenRaw(author, time.Now().Unix(), nil) } -func (c *BugCache) OpenRaw(author bug.Person, unixTime int64, metadata map[string]string) error { +func (c *BugCache) OpenRaw(author *identity.Identity, unixTime int64, metadata map[string]string) error { op, err := bug.Open(c.bug, author, unixTime) if err != nil { return err @@ -158,7 +160,7 @@ func (c *BugCache) OpenRaw(author bug.Person, unixTime int64, metadata map[strin } func (c *BugCache) Close() error { - author, err := bug.GetUser(c.repoCache.repo) + author, err := identity.GetIdentity(c.repoCache.repo) if err != nil { return err } @@ -166,7 +168,7 @@ func (c *BugCache) Close() error { return c.CloseRaw(author, time.Now().Unix(), nil) } -func (c *BugCache) CloseRaw(author bug.Person, unixTime int64, metadata map[string]string) error { +func (c *BugCache) CloseRaw(author *identity.Identity, unixTime int64, metadata map[string]string) error { op, err := bug.Close(c.bug, author, unixTime) if err != nil { return err @@ -180,7 +182,7 @@ func (c *BugCache) CloseRaw(author bug.Person, unixTime int64, metadata map[stri } func (c *BugCache) SetTitle(title string) error { - author, err := bug.GetUser(c.repoCache.repo) + author, err := identity.GetIdentity(c.repoCache.repo) if err != nil { return err } @@ -188,7 +190,7 @@ func (c *BugCache) SetTitle(title string) error { 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 { +func (c *BugCache) SetTitleRaw(author *identity.Identity, unixTime int64, title string, metadata map[string]string) error { op, err := bug.SetTitle(c.bug, author, unixTime, title) if err != nil { return err @@ -202,7 +204,7 @@ func (c *BugCache) SetTitleRaw(author bug.Person, unixTime int64, title string, } func (c *BugCache) EditComment(target git.Hash, message string) error { - author, err := bug.GetUser(c.repoCache.repo) + author, err := identity.GetIdentity(c.repoCache.repo) if err != nil { return err } @@ -210,7 +212,7 @@ func (c *BugCache) EditComment(target git.Hash, message string) error { return c.EditCommentRaw(author, time.Now().Unix(), target, message, nil) } -func (c *BugCache) EditCommentRaw(author bug.Person, unixTime int64, target git.Hash, message string, metadata map[string]string) error { +func (c *BugCache) EditCommentRaw(author *identity.Identity, 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 diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go index 7a11fa82..77c18175 100644 --- a/cache/bug_excerpt.go +++ b/cache/bug_excerpt.go @@ -3,6 +3,8 @@ package cache import ( "encoding/gob" + "github.com/MichaelMure/git-bug/identity" + "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/util/lamport" ) @@ -18,7 +20,7 @@ type BugExcerpt struct { EditUnixTime int64 Status bug.Status - Author bug.Person + Author *identity.Identity Labels []bug.Label CreateMetadata map[string]string diff --git a/cache/repo_cache.go b/cache/repo_cache.go index 286e27a5..a149fd73 100644 --- a/cache/repo_cache.go +++ b/cache/repo_cache.go @@ -14,6 +14,7 @@ import ( "time" "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/repository" "github.com/MichaelMure/git-bug/util/git" "github.com/MichaelMure/git-bug/util/process" @@ -376,7 +377,7 @@ func (c *RepoCache) NewBug(title string, message string) (*BugCache, error) { // NewBugWithFiles create a new bug with attached files for the message // The new bug is written in the repository (commit) func (c *RepoCache) NewBugWithFiles(title string, message string, files []git.Hash) (*BugCache, error) { - author, err := bug.GetUser(c.repo) + author, err := identity.GetIdentity(c.repo) if err != nil { return nil, err } @@ -387,7 +388,7 @@ func (c *RepoCache) NewBugWithFiles(title string, message string, files []git.Ha // 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) { +func (c *RepoCache) NewBugRaw(author *identity.Identity, unixTime int64, title string, message string, files []git.Hash, metadata map[string]string) (*BugCache, error) { b, op, err := bug.CreateWithFiles(author, unixTime, title, message, files) if err != nil { return nil, err |