aboutsummaryrefslogtreecommitdiffstats
path: root/cache
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-21 18:18:51 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-21 18:53:37 +0200
commit82eaceffc1d750832a2a66f206749d2dca968cce (patch)
tree1431c8f1fd9baa689b850da7f104d12c20b1d8a7 /cache
parent6a575fbf483e2b28821908f67e87637d9e5cea75 (diff)
downloadgit-bug-82eaceffc1d750832a2a66f206749d2dca968cce.tar.gz
repo: split the Repo interface to avoid abstraction leak in RepoCache
Diffstat (limited to 'cache')
-rw-r--r--cache/multi_repo_cache.go4
-rw-r--r--cache/repo_cache.go26
2 files changed, 22 insertions, 8 deletions
diff --git a/cache/multi_repo_cache.go b/cache/multi_repo_cache.go
index c5328b7e..ec435ff2 100644
--- a/cache/multi_repo_cache.go
+++ b/cache/multi_repo_cache.go
@@ -19,7 +19,7 @@ func NewMultiRepoCache() MultiRepoCache {
}
// RegisterRepository register a named repository. Use this for multi-repo setup
-func (c *MultiRepoCache) RegisterRepository(ref string, repo repository.Repo) error {
+func (c *MultiRepoCache) RegisterRepository(ref string, repo repository.ClockedRepo) error {
r, err := NewRepoCache(repo)
if err != nil {
return err
@@ -30,7 +30,7 @@ func (c *MultiRepoCache) RegisterRepository(ref string, repo repository.Repo) er
}
// RegisterDefaultRepository register a unnamed repository. Use this for mono-repo setup
-func (c *MultiRepoCache) RegisterDefaultRepository(repo repository.Repo) error {
+func (c *MultiRepoCache) RegisterDefaultRepository(repo repository.ClockedRepo) error {
r, err := NewRepoCache(repo)
if err != nil {
return err
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index 26f2855f..a43c6684 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -24,14 +24,14 @@ const formatVersion = 1
type RepoCache struct {
// the underlying repo
- repo repository.Repo
+ repo repository.ClockedRepo
// excerpt of bugs data for all bugs
excerpts map[string]*BugExcerpt
// bug loaded in memory
bugs map[string]*BugCache
}
-func NewRepoCache(r repository.Repo) (*RepoCache, error) {
+func NewRepoCache(r repository.ClockedRepo) (*RepoCache, error) {
c := &RepoCache{
repo: r,
bugs: make(map[string]*BugCache),
@@ -55,10 +55,24 @@ func NewRepoCache(r repository.Repo) (*RepoCache, error) {
return c, c.write()
}
-// Repository return the underlying repository.
-// If you use this, make sure to never change the repo state.
-func (c *RepoCache) Repository() repository.Repo {
- return c.repo
+// GetPath returns the path to the repo.
+func (c *RepoCache) GetPath() string {
+ return c.repo.GetPath()
+}
+
+// GetPath returns the path to the repo.
+func (c *RepoCache) GetCoreEditor() (string, error) {
+ return c.repo.GetCoreEditor()
+}
+
+// GetUserName returns the name the the user has used to configure git
+func (c *RepoCache) GetUserName() (string, error) {
+ return c.repo.GetUserName()
+}
+
+// GetUserEmail returns the email address that the user has used to configure git.
+func (c *RepoCache) GetUserEmail() (string, error) {
+ return c.repo.GetUserEmail()
}
func (c *RepoCache) lock() error {