aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-04-11 20:04:44 +0200
committerMichael Muré <batolettre@gmail.com>2019-04-11 20:04:44 +0200
commit5eeeae7cdf24083277076041c4e8cdc6b4737fda (patch)
tree0e1e8b6a44650a146a296b3710757c309d420617
parent4fac4abbcd357b9a8a99222af15a7c5fca9f5633 (diff)
downloadgit-bug-5eeeae7cdf24083277076041c4e8cdc6b4737fda.tar.gz
commands: fix ls not displaying the new Identities properly
-rw-r--r--cache/bug_excerpt.go14
-rw-r--r--commands/ls.go14
-rw-r--r--doc/man/git-bug-ls.18
-rw-r--r--doc/man/git-bug-show.12
-rw-r--r--doc/md/git-bug_ls.md18
-rw-r--r--doc/md/git-bug_show.md2
-rw-r--r--misc/bash_completion/git-bug6
7 files changed, 53 insertions, 11 deletions
diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go
index d78def4e..8e9e5e37 100644
--- a/cache/bug_excerpt.go
+++ b/cache/bug_excerpt.go
@@ -2,6 +2,7 @@ package cache
import (
"encoding/gob"
+ "fmt"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/identity"
@@ -45,6 +46,19 @@ type LegacyAuthorExcerpt struct {
Login string
}
+func (l LegacyAuthorExcerpt) DisplayName() string {
+ switch {
+ case l.Name == "" && l.Login != "":
+ return l.Login
+ case l.Name != "" && l.Login == "":
+ return l.Name
+ case l.Name != "" && l.Login != "":
+ return fmt.Sprintf("%s (%s)", l.Name, l.Login)
+ }
+
+ panic("invalid person data")
+}
+
func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt {
participantsIds := make([]string, len(snap.Participants))
for i, participant := range snap.Participants {
diff --git a/commands/ls.go b/commands/ls.go
index ca74cc46..22940f2f 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -52,9 +52,21 @@ func runLsBug(cmd *cobra.Command, args []string) error {
return err
}
+ var name string
+ if b.AuthorId != "" {
+ author, err := backend.ResolveIdentityExcerpt(b.AuthorId)
+ if err != nil {
+ name = "<missing author data>"
+ } else {
+ name = author.DisplayName()
+ }
+ } else {
+ name = b.LegacyAuthor.DisplayName()
+ }
+
// truncate + pad if needed
titleFmt := fmt.Sprintf("%-50.50s", b.Title)
- authorFmt := fmt.Sprintf("%-15.15s", b.LegacyAuthor.Name)
+ authorFmt := fmt.Sprintf("%-15.15s", name)
fmt.Printf("%s %s\t%s\t%s\tC:%d L:%d\n",
colors.Cyan(b.HumanId()),
diff --git a/doc/man/git-bug-ls.1 b/doc/man/git-bug-ls.1
index 3d2bc4e8..aae57c1d 100644
--- a/doc/man/git-bug-ls.1
+++ b/doc/man/git-bug-ls.1
@@ -31,6 +31,14 @@ You can pass an additional query to filter and order the list. This query can be
Filter by author
.PP
+\fB\-p\fP, \fB\-\-participant\fP=[]
+ Filter by participant
+
+.PP
+\fB\-A\fP, \fB\-\-actor\fP=[]
+ Filter by actor
+
+.PP
\fB\-l\fP, \fB\-\-label\fP=[]
Filter by label
diff --git a/doc/man/git-bug-show.1 b/doc/man/git-bug-show.1
index 3dfb4419..9ad9c019 100644
--- a/doc/man/git-bug-show.1
+++ b/doc/man/git-bug-show.1
@@ -21,7 +21,7 @@ Display the details of a bug.
.SH OPTIONS
.PP
\fB\-f\fP, \fB\-\-field\fP=""
- Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title]
+ Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title,actors,participants]
.PP
\fB\-h\fP, \fB\-\-help\fP[=false]
diff --git a/doc/md/git-bug_ls.md b/doc/md/git-bug_ls.md
index 9ab71884..085a70c9 100644
--- a/doc/md/git-bug_ls.md
+++ b/doc/md/git-bug_ls.md
@@ -26,14 +26,16 @@ git bug ls --status closed --by creation
### Options
```
- -s, --status strings Filter by status. Valid values are [open,closed]
- -a, --author strings Filter by author
- -l, --label strings Filter by label
- -t, --title strings Filter by title
- -n, --no strings Filter by absence of something. Valid values are [label]
- -b, --by string Sort the results by a characteristic. Valid values are [id,creation,edit] (default "creation")
- -d, --direction string Select the sorting direction. Valid values are [asc,desc] (default "asc")
- -h, --help help for ls
+ -s, --status strings Filter by status. Valid values are [open,closed]
+ -a, --author strings Filter by author
+ -p, --participant strings Filter by participant
+ -A, --actor strings Filter by actor
+ -l, --label strings Filter by label
+ -t, --title strings Filter by title
+ -n, --no strings Filter by absence of something. Valid values are [label]
+ -b, --by string Sort the results by a characteristic. Valid values are [id,creation,edit] (default "creation")
+ -d, --direction string Select the sorting direction. Valid values are [asc,desc] (default "asc")
+ -h, --help help for ls
```
### SEE ALSO
diff --git a/doc/md/git-bug_show.md b/doc/md/git-bug_show.md
index 21d5460c..40152ede 100644
--- a/doc/md/git-bug_show.md
+++ b/doc/md/git-bug_show.md
@@ -13,7 +13,7 @@ git-bug show [<id>] [flags]
### Options
```
- -f, --field string Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title]
+ -f, --field string Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title,actors,participants]
-h, --help help for show
```
diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug
index 543136b5..682df96d 100644
--- a/misc/bash_completion/git-bug
+++ b/misc/bash_completion/git-bug
@@ -532,6 +532,12 @@ _git-bug_ls()
flags+=("--author=")
two_word_flags+=("-a")
local_nonpersistent_flags+=("--author=")
+ flags+=("--participant=")
+ two_word_flags+=("-p")
+ local_nonpersistent_flags+=("--participant=")
+ flags+=("--actor=")
+ two_word_flags+=("-A")
+ local_nonpersistent_flags+=("--actor=")
flags+=("--label=")
two_word_flags+=("-l")
local_nonpersistent_flags+=("--label=")