aboutsummaryrefslogtreecommitdiffstats
path: root/cache/identity_excerpt.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-25 21:35:57 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-25 21:35:57 +0100
commit893de4f5c0e852fac9a73e0c0243bc038af75f17 (patch)
tree6129d0a6e2efbfa81b26534ee5aeb65ba1261bfe /cache/identity_excerpt.go
parent68acfa519ab6656648d1e976db2a4190bbeb5f44 (diff)
downloadgit-bug-893de4f5c0e852fac9a73e0c0243bc038af75f17.tar.gz
identity: bring back the login to hold that info from bridges (purely informational)
Diffstat (limited to 'cache/identity_excerpt.go')
-rw-r--r--cache/identity_excerpt.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/cache/identity_excerpt.go b/cache/identity_excerpt.go
index 06788aa5..18514e9a 100644
--- a/cache/identity_excerpt.go
+++ b/cache/identity_excerpt.go
@@ -2,6 +2,7 @@ package cache
import (
"encoding/gob"
+ "fmt"
"strings"
"github.com/MichaelMure/git-bug/entity"
@@ -20,6 +21,7 @@ type IdentityExcerpt struct {
Id entity.Id
Name string
+ Login string
ImmutableMetadata map[string]string
}
@@ -27,6 +29,7 @@ func NewIdentityExcerpt(i *identity.Identity) *IdentityExcerpt {
return &IdentityExcerpt{
Id: i.Id(),
Name: i.Name(),
+ Login: i.Login(),
ImmutableMetadata: i.ImmutableMetadata(),
}
}
@@ -34,13 +37,23 @@ func NewIdentityExcerpt(i *identity.Identity) *IdentityExcerpt {
// DisplayName return a non-empty string to display, representing the
// identity, based on the non-empty values.
func (i *IdentityExcerpt) 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")
}
// Match matches a query with the identity name, login and ID prefixes
func (i *IdentityExcerpt) Match(query string) bool {
return i.Id.HasPrefix(query) ||
- strings.Contains(strings.ToLower(i.Name), query)
+ strings.Contains(strings.ToLower(i.Name), query) ||
+ strings.Contains(strings.ToLower(i.Login), query)
}
/*