aboutsummaryrefslogtreecommitdiffstats
path: root/identity/identity.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-26 07:38:13 +0100
committerGitHub <noreply@github.com>2020-02-26 07:38:13 +0100
commit0c791483286ce2ed845bbc77b2a2899149ad83c5 (patch)
tree6129d0a6e2efbfa81b26534ee5aeb65ba1261bfe /identity/identity.go
parent68acfa519ab6656648d1e976db2a4190bbeb5f44 (diff)
parent893de4f5c0e852fac9a73e0c0243bc038af75f17 (diff)
downloadgit-bug-0c791483286ce2ed845bbc77b2a2899149ad83c5.tar.gz
Merge pull request #343 from MichaelMure/login-is-back
identity: bring back the login to hold that info from bridges
Diffstat (limited to 'identity/identity.go')
-rw-r--r--identity/identity.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/identity/identity.go b/identity/identity.go
index b5222a3e..6b71fa35 100644
--- a/identity/identity.go
+++ b/identity/identity.go
@@ -56,13 +56,14 @@ func NewIdentity(name string, email string) *Identity {
}
}
-func NewIdentityFull(name string, email string, avatarUrl string) *Identity {
+func NewIdentityFull(name string, email string, login string, avatarUrl string) *Identity {
return &Identity{
id: entity.UnsetId,
versions: []*Version{
{
name: name,
email: email,
+ login: login,
avatarURL: avatarUrl,
nonce: makeNonce(20),
},
@@ -282,6 +283,7 @@ func IsUserIdentitySet(repo repository.Repo) (bool, error) {
type Mutator struct {
Name string
+ Login string
Email string
AvatarUrl string
Keys []*Key
@@ -292,6 +294,7 @@ 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(),
}
@@ -302,6 +305,7 @@ func (i *Identity) Mutate(f func(orig Mutator) Mutator) {
i.versions = append(i.versions, &Version{
name: mutated.Name,
email: mutated.Email,
+ login: mutated.Login,
avatarURL: mutated.AvatarUrl,
keys: mutated.Keys,
})
@@ -510,6 +514,11 @@ 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
@@ -538,7 +547,16 @@ 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 {
- return i.Name()
+ 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")
}
// IsProtected return true if the chain of git commits started to be signed.