Commit 6bf4591bd7

6bf4591bd7b8c66f400e6dae05081a021793bd82

parent: 86c82f63ee

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-28 08:17 UTC

repo show: truncate the mirror's last-sync time to the second

Closes #268

Layout: unified · split

CHANGELOG.org +2
@@ -96,6 +96,8 @@ for the eighteen commands whose CLI path differs from the registry's
96 =checks (2):=, =reviews (3):= (#268). 96 =checks (2):=, =reviews (3):= (#268).
97- =repo readme <owner/name> [--ref <ref>]= prints a repository's README, 97- =repo readme <owner/name> [--ref <ref>]= prints a repository's README,
98 picked the same way the web page picks one (#268). 98 picked the same way the web page picks one (#268).
99- =repo show='s mirror table truncates =LAST SYNC= to the second, like
100 every other timestamp in a view (#268).
99 101
100* v1.36.0 — 2026-09-23 102* v1.36.0 — 2026-09-23
101 103
internal/control/repo.go +1 −1
@@ -471,7 +471,7 @@ func runRepoShow(c *Ctx, args []string) int {
471 if m.LastError != "" { 471 if m.LastError != "" {
472 status = "error: " + m.LastError 472 status = "error: " + m.LastError
473 } 473 }
474 tb.row(cText(m.Direction), cFlex(m.URL), cText(orDash(m.LastSync)), cState(status)) 474 tb.row(cText(m.Direction), cFlex(m.URL), cText(orDash(c.when(m.LastSync))), cState(status))
475 } 475 }
476 tb.flush() 476 tb.flush()
477 } 477 }
internal/control/repo_test.go added +38
@@ -0,0 +1,38 @@
1package control
2
3import (
4 "bytes"
5 "strings"
6 "testing"
7
8 "gitbay.org/gitbay/internal/protocol"
9 "gitbay.org/gitbay/internal/store"
10)
11
12// repo show's mirror row must go through the same second-truncation every
13// other timestamp in a view uses, not print the store's raw milliseconds.
14func TestRepoShowMirrorTimeIsTruncatedToTheSecond(t *testing.T) {
15 st, repo, uid := newQueueTestRepo(t)
16 id, err := st.AddMirror(repo.ID, "push", "ssh://example.test/x.git", "", "")
17 if err != nil {
18 t.Fatal(err)
19 }
20 if err := st.SetMirrorResult(id, ""); err != nil {
21 t.Fatal(err)
22 }
23 if _, err := st.DB.Exec("UPDATE mirrors SET last_sync = ? WHERE id = ?", "2026-09-24T15:31:50.839Z", id); err != nil {
24 t.Fatal(err)
25 }
26
27 c, errOut := pruneCtx(st, t.TempDir(), store.User{ID: uid, Username: "alice", IsAdmin: true})
28 if code := runRepoShow(c, []string{repo.Path()}); code != protocol.ExitOK {
29 t.Fatalf("exit %d: %s", code, errOut.String())
30 }
31 out := c.Stdout.(*bytes.Buffer).String()
32 if strings.Contains(out, ".839Z") {
33 t.Errorf("milliseconds leaked: %s", out)
34 }
35 if !strings.Contains(out, "2026-09-24T15:31:50Z") {
36 t.Errorf("no truncated timestamp: %s", out)
37 }
38}