aboutsummaryrefslogtreecommitdiffstats
path: root/cache/repo_cache_common.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2023-01-14 14:21:01 +0100
committerGitHub <noreply@github.com>2023-01-14 14:21:01 +0100
commit98eb1c111efb22ddb02ab71779f1862abab4baa5 (patch)
treebb4d8bc2c1fd5614d274dab272e7dae03da5496b /cache/repo_cache_common.go
parent9c50a359704f4edd2f33df6d256e032feae3a576 (diff)
parent5bf274e64a3486bba21edd9bf455089839219f25 (diff)
downloadgit-bug-98eb1c111efb22ddb02ab71779f1862abab4baa5.tar.gz
Merge pull request #933 from zinderic/feat-cleanup-subcommand
add cleanup sub-command that remove local bugs and identities
Diffstat (limited to 'cache/repo_cache_common.go')
-rw-r--r--cache/repo_cache_common.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/cache/repo_cache_common.go b/cache/repo_cache_common.go
index f768b8e2..759536bd 100644
--- a/cache/repo_cache_common.go
+++ b/cache/repo_cache_common.go
@@ -3,12 +3,12 @@ package cache
import (
"sync"
- "github.com/go-git/go-billy/v5"
"github.com/pkg/errors"
"github.com/MichaelMure/git-bug/entities/identity"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/repository"
+ "github.com/MichaelMure/git-bug/util/multierr"
)
func (c *RepoCache) Name() string {
@@ -56,7 +56,7 @@ func (c *RepoCache) GetRemotes() (map[string]string, error) {
}
// LocalStorage return a billy.Filesystem giving access to $RepoPath/.git/git-bug
-func (c *RepoCache) LocalStorage() billy.Filesystem {
+func (c *RepoCache) LocalStorage() repository.LocalStorage {
return c.repo.LocalStorage()
}
@@ -82,6 +82,15 @@ func (c *RepoCache) Fetch(remote string) (string, error) {
return c.repo.FetchRefs(remote, prefixes...)
}
+// RemoveAll deletes all entities from the cache and the disk.
+func (c *RepoCache) RemoveAll() error {
+ var errWait multierr.ErrWaitGroup
+ for _, mgmt := range c.subcaches {
+ errWait.Go(mgmt.RemoveAll)
+ }
+ return errWait.Wait()
+}
+
// MergeAll will merge all the available remote bug and identities
func (c *RepoCache) MergeAll(remote string) <-chan entity.MergeResult {
out := make(chan entity.MergeResult)
@@ -163,6 +172,19 @@ func (c *RepoCache) SetUserIdentity(i *IdentityCache) error {
return nil
}
+func (c *RepoCache) ClearUserIdentity() error {
+ c.muUserIdentity.Lock()
+ defer c.muUserIdentity.Unlock()
+
+ err := identity.ClearUserIdentity(c.repo)
+ if err != nil {
+ return err
+ }
+
+ c.userIdentityId = ""
+ return nil
+}
+
func (c *RepoCache) GetUserIdentity() (*IdentityCache, error) {
c.muUserIdentity.RLock()
if c.userIdentityId != "" {