aboutsummaryrefslogtreecommitdiffstats
path: root/identity
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-09-27 20:31:09 +0200
committerMichael Muré <batolettre@gmail.com>2020-09-29 20:42:21 +0200
commiteb88f0e4463ea1aef5494314fa2a9607aaa262dd (patch)
treee1c74172f72c9fd39a7694fedd51c5529dbcdbf8 /identity
parent4f172432b1fb983c57aa258a93e24cbb36c8e1fb (diff)
downloadgit-bug-eb88f0e4463ea1aef5494314fa2a9607aaa262dd.tar.gz
repo: more config related bug fixes
Diffstat (limited to 'identity')
-rw-r--r--identity/identity_user.go27
1 files changed, 12 insertions, 15 deletions
diff --git a/identity/identity_user.go b/identity/identity_user.go
index 60622c12..cd67459e 100644
--- a/identity/identity_user.go
+++ b/identity/identity_user.go
@@ -35,24 +35,19 @@ func GetUserIdentity(repo repository.Repo) (*Identity, error) {
}
func GetUserIdentityId(repo repository.Repo) (entity.Id, error) {
- configs, err := repo.LocalConfig().ReadAll(identityConfigKey)
- if err != nil {
- return entity.UnsetId, err
- }
-
- if len(configs) == 0 {
+ val, err := repo.LocalConfig().ReadString(identityConfigKey)
+ if err == repository.ErrNoConfigEntry {
return entity.UnsetId, ErrNoIdentitySet
}
-
- if len(configs) > 1 {
+ if err == repository.ErrMultipleConfigEntry {
return entity.UnsetId, ErrMultipleIdentitiesSet
}
-
- var id entity.Id
- for _, val := range configs {
- id = entity.Id(val)
+ if err != nil {
+ return entity.UnsetId, err
}
+ var id = entity.Id(val)
+
if err := id.Validate(); err != nil {
return entity.UnsetId, err
}
@@ -62,10 +57,12 @@ func GetUserIdentityId(repo repository.Repo) (entity.Id, error) {
// IsUserIdentitySet say if the user has set his identity
func IsUserIdentitySet(repo repository.Repo) (bool, error) {
- configs, err := repo.LocalConfig().ReadAll(identityConfigKey)
+ _, err := repo.LocalConfig().ReadString(identityConfigKey)
+ if err == repository.ErrNoConfigEntry {
+ return false, nil
+ }
if err != nil {
return false, err
}
-
- return len(configs) == 1, nil
+ return true, nil
}