aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cache/bug_excerpt.go25
-rw-r--r--cache/filter.go4
-rw-r--r--cache/repo_cache.go9
-rw-r--r--commands/ls.go6
4 files changed, 24 insertions, 20 deletions
diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go
index 86424a0a..a50d8c66 100644
--- a/cache/bug_excerpt.go
+++ b/cache/bug_excerpt.go
@@ -23,11 +23,16 @@ type BugExcerpt struct {
CreateUnixTime int64
EditUnixTime int64
- Title string
Status bug.Status
- Author identity.Interface
- LenComments int
Labels []bug.Label
+ Title string
+ LenComments int
+
+ // If author is identity.Bare, LegacyAuthor is set
+ // If author is identity.Identity, AuthorId is set and data is deported
+ // in a IdentityExcerpt
+ LegacyAuthor LegacyAuthorExcerpt
+ AuthorId string
CreateMetadata map[string]string
}
@@ -45,13 +50,25 @@ func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt {
EditLamportTime: b.EditLamportTime(),
CreateUnixTime: b.FirstOp().GetUnixTime(),
EditUnixTime: snap.LastEditUnix(),
- Title: snap.Title,
Status: snap.Status,
Labels: snap.Labels,
+ Title: snap.Title,
LenComments: len(snap.Comments),
CreateMetadata: b.FirstOp().AllMetadata(),
}
+ switch snap.Author.(type) {
+ case *identity.Identity:
+ e.AuthorId = snap.Author.Id()
+ case *identity.Bare:
+ e.LegacyAuthor = LegacyAuthorExcerpt{
+ Login: snap.Author.Login(),
+ Name: snap.Author.Name(),
+ }
+ default:
+ panic("unhandled identity type")
+ }
+
return e
}
diff --git a/cache/filter.go b/cache/filter.go
index dc134260..a5aca8fb 100644
--- a/cache/filter.go
+++ b/cache/filter.go
@@ -57,7 +57,7 @@ func LabelFilter(label string) Filter {
// TitleFilter return a Filter that match a title
func TitleFilter(title string) Filter {
- return func(excerpt *BugExcerpt) bool {
+ return func(repo *RepoCache, excerpt *BugExcerpt) bool {
return strings.Contains(excerpt.Title, title)
}
}
@@ -96,7 +96,7 @@ func (f *Filters) Match(repoCache *RepoCache, excerpt *BugExcerpt) bool {
return false
}
- if match := f.andMatch(f.Title, excerpt); !match {
+ if match := f.andMatch(f.Title, repoCache, excerpt); !match {
return false
}
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index fd5d0865..2b0fa360 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -386,15 +386,6 @@ func (c *RepoCache) ResolveBug(id string) (*BugCache, error) {
return cached, nil
}
-// ResolveBugExcerpt retrieve a BugExcerpt matching the exact given id
-func (c *RepoCache) ResolveBugExcerpt(id string) (*BugExcerpt, error) {
- e, ok := c.excerpts[id]
- if !ok {
- return nil, bug.ErrBugNotExist
- }
-
- return e, nil
-}
// ResolveBugExcerpt retrieve a BugExcerpt matching the exact given id
func (c *RepoCache) ResolveBugExcerpt(id string) (*BugExcerpt, error) {
diff --git a/commands/ls.go b/commands/ls.go
index 7dbac96e..75819f1a 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -52,14 +52,10 @@ func runLsBug(cmd *cobra.Command, args []string) error {
// truncate + pad if needed
titleFmt := fmt.Sprintf("%-50.50s", b.Title)
- authorFmt := fmt.Sprintf("%-15.15s", b.Author.Name)
+ authorFmt := fmt.Sprintf("%-15.15s", b.LegacyAuthor.Name)
fmt.Printf("%s %s\t%s\t%s\tC:%d L:%d\n",
-<<<<<<< HEAD
colors.Cyan(b.HumanId()),
-=======
- colors.Cyan(b.Id),
->>>>>>> Made requested changes
colors.Yellow(b.Status),
titleFmt,
colors.Magenta(authorFmt),