From 3ac8657a49bfb90460f4fc9e4ba9405fa485f643 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 19 Oct 2026 10:46:57 +0200 Subject: [PATCH] Carry the source fingerprint in the builds list, so builds can say it (issue 1208) Issue 1204's line never showed: chainBuildList copied each build field by field and left the fingerprint out. --- internal/inventory/builds_test.go | 30 ++++++++++++++++++++++++++++++ internal/inventory/chain_builds.go | 4 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/internal/inventory/builds_test.go b/internal/inventory/builds_test.go index bfdbd6fd..10c653d8 100644 --- a/internal/inventory/builds_test.go +++ b/internal/inventory/builds_test.go @@ -256,3 +256,33 @@ func TestAFailedNewerBuildLeavesTheBuildSourceStale(t *testing.T) { t.Fatalf("after a newer failed build the proxy reads as %+v", got) } } + +// novox/hq issue 1208: the list builds reads carries each build's source fingerprint, so the verb can say it. +func TestTheBuildsListCarriesTheSourceFingerprint(t *testing.T) { + inv := fresh(t) + ctx := context.Background() + pinned := aBuild("1", "shell", "") + pinned.SourceFingerprint = "src1:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + if err := inv.RecordBuild(ctx, pinned); err != nil { + t.Fatal(err) + } + if err := inv.RecordBuild(ctx, aBuild("2", "other", "")); err != nil { + t.Fatal(err) + } + got, err := inv.Builds(ctx, "", 10) + if err != nil { + t.Fatal(err) + } + says := map[string]string{} + for _, b := range got { + says[b.Module] = b.SourceFingerprint + } + // 1208/AC1 + if says["shell"] != pinned.SourceFingerprint { + t.Errorf("the list says %q for shell; want %q", says["shell"], pinned.SourceFingerprint) + } + // 1208/AC2 + if fp, listed := says["other"]; !listed || fp != "" { + t.Errorf("a build with no fingerprint is listed with %q (listed %v); want it listed with none", fp, listed) + } +} diff --git a/internal/inventory/chain_builds.go b/internal/inventory/chain_builds.go index c6db6b75..25e4aa79 100644 --- a/internal/inventory/chain_builds.go +++ b/internal/inventory/chain_builds.go @@ -618,7 +618,9 @@ func (i *Inventory) chainBuildList(ctx context.Context, c *chain.Chain, module s for _, b := range all { if module == "" || b.Module == module { out = append(out, Build{ID: b.ID, Repository: b.Repository, Ref: b.Ref, Module: b.Module, Commit: b.Commit, - On: b.On, Failed: b.Failed, Made: b.Made, Asked: b.Asked, At: b.At, ReuseKey: b.ReuseKey, Published: b.Published}) + On: b.On, Failed: b.Failed, Made: b.Made, Asked: b.Asked, At: b.At, ReuseKey: b.ReuseKey, Published: b.Published, + // What it was made from, which builds says (novox/hq issue 1208). + SourceFingerprint: b.SourceFingerprint}) } } sort.SliceStable(out, func(a, b int) bool {