diff options
Diffstat (limited to 'cache')
-rw-r--r-- | cache/multi_repo_cache.go | 4 | ||||
-rw-r--r-- | cache/repo_cache.go | 18 | ||||
-rw-r--r-- | cache/repo_cache_test.go | 8 |
3 files changed, 15 insertions, 15 deletions
diff --git a/cache/multi_repo_cache.go b/cache/multi_repo_cache.go index da1c26bd..a55bbcce 100644 --- a/cache/multi_repo_cache.go +++ b/cache/multi_repo_cache.go @@ -41,7 +41,7 @@ func (c *MultiRepoCache) RegisterDefaultRepository(repo repository.ClockedRepo) return nil } -// ResolveRepo retrieve a repository by name +// DefaultRepo retrieve the default repository func (c *MultiRepoCache) DefaultRepo() (*RepoCache, error) { if len(c.repos) != 1 { return nil, fmt.Errorf("repository is not unique") @@ -54,7 +54,7 @@ func (c *MultiRepoCache) DefaultRepo() (*RepoCache, error) { panic("unreachable") } -// DefaultRepo retrieve the default repository +// ResolveRepo retrieve a repository with a reference func (c *MultiRepoCache) ResolveRepo(ref string) (*RepoCache, error) { r, ok := c.repos[ref] if !ok { diff --git a/cache/repo_cache.go b/cache/repo_cache.go index b3b2ea1e..a80bc7c9 100644 --- a/cache/repo_cache.go +++ b/cache/repo_cache.go @@ -563,16 +563,16 @@ func (c *RepoCache) ValidLabels() []bug.Label { // NewBug create a new bug // The new bug is written in the repository (commit) -func (c *RepoCache) NewBug(title string, message string) (*BugCache, error) { +func (c *RepoCache) NewBug(title string, message string) (*BugCache, *bug.CreateOperation, error) { return c.NewBugWithFiles(title, message, nil) } // 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) { +func (c *RepoCache) NewBugWithFiles(title string, message string, files []git.Hash) (*BugCache, *bug.CreateOperation, error) { author, err := c.GetUserIdentity() if err != nil { - return nil, err + return nil, nil, err } return c.NewBugRaw(author, time.Now().Unix(), title, message, files, nil) @@ -581,10 +581,10 @@ 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 *IdentityCache, unixTime int64, title string, message string, files []git.Hash, metadata map[string]string) (*BugCache, error) { +func (c *RepoCache) NewBugRaw(author *IdentityCache, unixTime int64, title string, message string, files []git.Hash, metadata map[string]string) (*BugCache, *bug.CreateOperation, error) { b, op, err := bug.CreateWithFiles(author.Identity, unixTime, title, message, files) if err != nil { - return nil, err + return nil, nil, err } for key, value := range metadata { @@ -593,11 +593,11 @@ func (c *RepoCache) NewBugRaw(author *IdentityCache, unixTime int64, title strin err = b.Commit(c.repo) if err != nil { - return nil, err + return nil, nil, err } if _, has := c.bugs[b.Id()]; has { - return nil, fmt.Errorf("bug %s already exist in the cache", b.Id()) + return nil, nil, fmt.Errorf("bug %s already exist in the cache", b.Id()) } cached := NewBugCache(c, b) @@ -606,10 +606,10 @@ func (c *RepoCache) NewBugRaw(author *IdentityCache, unixTime int64, title strin // force the write of the excerpt err = c.bugUpdated(b.Id()) if err != nil { - return nil, err + return nil, nil, err } - return cached, nil + return cached, op, nil } // Fetch retrieve updates from a remote diff --git a/cache/repo_cache_test.go b/cache/repo_cache_test.go index 7e38b6bc..3e81674a 100644 --- a/cache/repo_cache_test.go +++ b/cache/repo_cache_test.go @@ -37,11 +37,11 @@ func TestCache(t *testing.T) { require.Len(t, cache.identities, 2) // Create a bug - bug1, err := cache.NewBug("title", "message") + bug1, _, err := cache.NewBug("title", "message") require.NoError(t, err) // It's possible to create two identical bugs - bug2, err := cache.NewBug("title", "message") + bug2, _, err := cache.NewBug("title", "message") require.NoError(t, err) // two identical bugs yield a different id @@ -125,7 +125,7 @@ func TestPushPull(t *testing.T) { require.NoError(t, err) // Create a bug in A - _, err = cacheA.NewBug("bug1", "message") + _, _, err = cacheA.NewBug("bug1", "message") require.NoError(t, err) // A --> remote --> B @@ -145,7 +145,7 @@ func TestPushPull(t *testing.T) { require.NoError(t, err) // B --> remote --> A - _, err = cacheB.NewBug("bug2", "message") + _, _, err = cacheB.NewBug("bug2", "message") require.NoError(t, err) _, err = cacheB.Push("origin") |