aboutsummaryrefslogtreecommitdiffstats
path: root/cache/identity_excerpt.go
diff options
context:
space:
mode:
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)
}
/*