aboutsummaryrefslogtreecommitdiffstats
path: root/entities/identity/identity.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 /entities/identity/identity.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 'entities/identity/identity.go')
-rw-r--r--entities/identity/identity.go50
1 files changed, 0 insertions, 50 deletions
diff --git a/entities/identity/identity.go b/entities/identity/identity.go
index 22ce652c..7c91b7b3 100644
--- a/entities/identity/identity.go
+++ b/entities/identity/identity.go
@@ -164,56 +164,6 @@ func ListLocalIds(repo repository.Repo) ([]entity.Id, error) {
return entity.RefsToIds(refs), nil
}
-// RemoveIdentity will remove a local identity from its entity.Id
-func RemoveIdentity(repo repository.ClockedRepo, id entity.Id) error {
- var fullMatches []string
-
- refs, err := repo.ListRefs(identityRefPattern + id.String())
- if err != nil {
- return err
- }
- if len(refs) > 1 {
- return entity.NewErrMultipleMatch(Typename, entity.RefsToIds(refs))
- }
- if len(refs) == 1 {
- // we have the identity locally
- fullMatches = append(fullMatches, refs[0])
- }
-
- remotes, err := repo.GetRemotes()
- if err != nil {
- return err
- }
-
- for remote := range remotes {
- remotePrefix := fmt.Sprintf(identityRemoteRefPattern+id.String(), remote)
- remoteRefs, err := repo.ListRefs(remotePrefix)
- if err != nil {
- return err
- }
- if len(remoteRefs) > 1 {
- return entity.NewErrMultipleMatch(Typename, entity.RefsToIds(refs))
- }
- if len(remoteRefs) == 1 {
- // found the identity in a remote
- fullMatches = append(fullMatches, remoteRefs[0])
- }
- }
-
- if len(fullMatches) == 0 {
- return entity.NewErrNotFound(Typename)
- }
-
- for _, ref := range fullMatches {
- err = repo.RemoveRef(ref)
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
// ReadAllLocal read and parse all local Identity
func ReadAllLocal(repo repository.ClockedRepo) <-chan entity.StreamedEntity[*Identity] {
return readAll(repo, identityRefPattern)