Commit 3e18e86aa4

3e18e86aa43773e99f2daad58c8ad7ad0479bcd8

parent: aa02c5e909

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-24 00:47 UTC

dashboard: none under an empty section

Ref #254

Layout: unified · split

internal/control/dashboard.go +13
@@ -175,6 +175,9 @@ func runDashboard(c *Ctx, args []string) int {
175 fmt.Fprintln(w, "open issues:") 175 fmt.Fprintln(w, "open issues:")
176 printDashboardItems(w, d.Issues, "#") 176 printDashboardItems(w, d.Issues, "#")
177 fmt.Fprintln(w, "pinned:") 177 fmt.Fprintln(w, "pinned:")
178 if len(d.Pinned) == 0 {
179 fmt.Fprintln(w, " none")
180 }
178 for _, p := range d.Pinned { 181 for _, p := range d.Pinned {
179 mark := "" 182 mark := ""
180 if p.Archived { 183 if p.Archived {
@@ -183,10 +186,16 @@ func runDashboard(c *Ctx, args []string) int {
183 fmt.Fprintf(w, " %s\t%s\t%s%s\n", p.Path, p.Visibility, p.Description, mark) 186 fmt.Fprintf(w, " %s\t%s\t%s%s\n", p.Path, p.Visibility, p.Description, mark)
184 } 187 }
185 fmt.Fprintln(w, "recent activity:") 188 fmt.Fprintln(w, "recent activity:")
189 if len(d.Activity) == 0 {
190 fmt.Fprintln(w, " none")
191 }
186 for _, e := range d.Activity { 192 for _, e := range d.Activity {
187 fmt.Fprintf(w, " %s\t%s\t%s\t%s\t%s\n", e.CreatedAt, e.Actor, e.Kind, e.Repo, string(e.Data)) 193 fmt.Fprintf(w, " %s\t%s\t%s\t%s\t%s\n", e.CreatedAt, e.Actor, e.Kind, e.Repo, string(e.Data))
188 } 194 }
189 fmt.Fprintln(w, "builds:") 195 fmt.Fprintln(w, "builds:")
196 if len(d.Builds) == 0 {
197 fmt.Fprintln(w, " none")
198 }
190 for _, b := range d.Builds { 199 for _, b := range d.Builds {
191 fmt.Fprintf(w, " %s\t%d\t%s\t%s\t%.10s\t%s\n", b.Repo, b.Number, b.Job, b.Status, b.SHA, b.Ref) 200 fmt.Fprintf(w, " %s\t%d\t%s\t%s\t%.10s\t%s\n", b.Repo, b.Number, b.Job, b.Status, b.SHA, b.Ref)
192 } 201 }
@@ -229,6 +238,10 @@ func runDashboard(c *Ctx, args []string) int {
229} 238}
230 239
231func printDashboardItems(w io.Writer, items []DashboardItem, marker string) { 240func printDashboardItems(w io.Writer, items []DashboardItem, marker string) {
241 if len(items) == 0 {
242 fmt.Fprintln(w, " none")
243 return
244 }
232 for _, item := range items { 245 for _, item := range items {
233 fmt.Fprintf(w, " %s%s%d\t%s\t%s\n", item.Repo, marker, item.Number, item.Title, item.Author) 246 fmt.Fprintf(w, " %s%s%d\t%s\t%s\n", item.Repo, marker, item.Number, item.Title, item.Author)
234 } 247 }
internal/control/dashboard_test.go +17
@@ -4,8 +4,25 @@ import (
4 "bytes" 4 "bytes"
5 "strings" 5 "strings"
6 "testing" 6 "testing"
7
8 "gitbay.org/gitbay/internal/protocol"
9 "gitbay.org/gitbay/internal/store"
7) 10)
8 11
12func TestDashboardEmptySectionsSayNone(t *testing.T) {
13 st, _, uid := newQueueTestRepo(t)
14 c, errOut := pruneCtx(st, t.TempDir(), store.User{ID: uid})
15 if code := Dispatch(c, []string{"dashboard"}); code != protocol.ExitOK {
16 t.Fatalf("exit %d: %s", code, errOut)
17 }
18 out := c.Stdout.(*bytes.Buffer).String()
19 for _, h := range []string{"waiting on your review:", "assigned to you:", "open merge requests:", "open issues:"} {
20 if !strings.Contains(out, h+"\n none\n") {
21 t.Errorf("%q not followed by none:\n%s", h, out)
22 }
23 }
24}
25
9// The push queue is the one worker queue whose worst failure — a key_id 26// The push queue is the one worker queue whose worst failure — a key_id
10// or team_id Apple did not issue, which config validation cannot check — 27// or team_id Apple did not issue, which config validation cannot check —
11// dead-letters every row on its first attempt with nothing but a log 28// dead-letters every row on its first attempt with nothing but a log