aboutsummaryrefslogtreecommitdiffstats
path: root/identity/identity.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-01-21 18:49:33 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-08 17:18:30 +0100
commit8da522d97af3dcaca8a8424e3541705c69779d6f (patch)
treeb67af18d752d3821bcbf62e362f699477eed9245 /identity/identity.go
parentb950c2580dfbf7672ee9e5e1e3f5b45c8cbc2788 (diff)
downloadgit-bug-8da522d97af3dcaca8a8424e3541705c69779d6f.tar.gz
wip
Diffstat (limited to 'identity/identity.go')
-rw-r--r--identity/identity.go40
1 files changed, 17 insertions, 23 deletions
diff --git a/identity/identity.go b/identity/identity.go
index a07bf858..655afd31 100644
--- a/identity/identity.go
+++ b/identity/identity.go
@@ -56,14 +56,13 @@ func NewIdentity(name string, email string) *Identity {
}
}
-func NewIdentityFull(name string, email string, login string, avatarUrl string) *Identity {
+func NewIdentityFull(name string, email string, avatarUrl string) *Identity {
return &Identity{
id: entity.UnsetId,
versions: []*Version{
{
name: name,
email: email,
- login: login,
avatarURL: avatarUrl,
nonce: makeNonce(20),
},
@@ -272,12 +271,18 @@ func IsUserIdentitySet(repo repository.Repo) (bool, error) {
return len(configs) == 1, nil
}
+type Mutator struct {
+ Name string
+ Email string
+ AvatarUrl string
+ Keys []Key
+}
+
// Mutate allow to create a new version of the Identity
-func (i *Identity) Mutate(f func(orig VersionMutator) VersionMutator) {
- orig := VersionMutator{
+func (i *Identity) Mutate(f func(orig Mutator) Mutator) {
+ orig := Mutator{
Name: i.Name(),
Email: i.Email(),
- Login: i.Login(),
AvatarUrl: i.AvatarUrl(),
Keys: i.Keys(),
}
@@ -288,7 +293,6 @@ func (i *Identity) Mutate(f func(orig VersionMutator) VersionMutator) {
i.versions = append(i.versions, &Version{
name: mutated.Name,
email: mutated.Email,
- login: mutated.Login,
avatarURL: mutated.AvatarUrl,
keys: mutated.Keys,
})
@@ -497,11 +501,6 @@ func (i *Identity) Email() string {
return i.lastVersion().email
}
-// Login return the last version of the login
-func (i *Identity) Login() string {
- return i.lastVersion().login
-}
-
// AvatarUrl return the last version of the Avatar URL
func (i *Identity) AvatarUrl() string {
return i.lastVersion().avatarURL
@@ -530,16 +529,7 @@ func (i *Identity) ValidKeysAtTime(time lamport.Time) []Key {
// DisplayName return a non-empty string to display, representing the
// identity, based on the non-empty values.
func (i *Identity) DisplayName() string {
- switch {
- case i.Name() == "" && i.Login() != "":
- return i.Login()
- case i.Name() != "" && i.Login() == "":
- return i.Name()
- case i.Name() != "" && i.Login() != "":
- return fmt.Sprintf("%s (%s)", i.Name(), i.Login())
- }
-
- panic("invalid person data")
+ return i.Name()
}
// IsProtected return true if the chain of git commits started to be signed.
@@ -559,9 +549,13 @@ func (i *Identity) LastModification() timestamp.Timestamp {
return timestamp.Timestamp(i.lastVersion().unixTime)
}
-// SetMetadata store arbitrary metadata along the last defined Version.
-// If the Version has been commit to git already, it won't be overwritten.
+// SetMetadata store arbitrary metadata along the last not-commit Version.
+// If the Version has been commit to git already, a new version is added and will need to be
+// commit.
func (i *Identity) SetMetadata(key string, value string) {
+ if i.lastVersion().commitHash != "" {
+
+ }
i.lastVersion().SetMetadata(key, value)
}