Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions pkg/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func (c *DiffCollector) Print(w io.Writer) {

if len(segs) > 1 {
turn := segs[0] + "\x00" + segs[1]
// A blank line sets every header block apart from the diff above it, so
// a breadcrumb sitting between two diffs stays visible — not just the
// turn banner, but a submodule hand-off or a bare target change too.
if i == 0 || key != lastKey {
fmt.Fprint(w, "\n")
}
if i == 0 || turn != lastTurn {
fmt.Fprint(w, diffTurnBanner(segs[0], segs[1], color))
}
Expand Down Expand Up @@ -132,7 +138,7 @@ func (c *DiffCollector) Print(w io.Writer) {
func DiffHeader(breadcrumb []string, target string, color bool) string {
segs := nonEmptySegs(breadcrumb)
if len(segs) > 1 {
return diffTurnBanner(segs[0], segs[1], color) +
return "\n" + diffTurnBanner(segs[0], segs[1], color) +
diffHandoffChain(segs, color) +
diffTargetLine(target, color)
}
Expand Down Expand Up @@ -163,17 +169,16 @@ func DiffHeader(breadcrumb []string, target string, color bool) string {
return b.String()
}

// diffTurnBanner heads one bulk turn: a leading blank line, then the root module
// as an inverted "≡ … ≡" chip (mirroring the log's root section header) followed
// by the turn's instance name in bold. This is the anchor the eye lands on, so
// turn boundaries stand out in a long batch.
// diffTurnBanner heads one bulk turn: the root module as an inverted "≡ … ≡" chip
// (mirroring the log's root section header) followed by the turn's instance name
// in bold. This is the anchor the eye lands on, so turn boundaries stand out in a
// long batch. Callers put the separating blank line above the whole header block.
func diffTurnBanner(root, turn string, color bool) string {
if color {
return "\n" +
diffColorInvert + diffColorRoot + diffColorBold + " ≡ " + root + " ≡ " + diffColorReset +
return diffColorInvert + diffColorRoot + diffColorBold + " ≡ " + root + " ≡ " + diffColorReset +
" " + diffColorBold + turn + diffColorReset + "\n"
}
return "\n[≡ " + root + " ≡] " + turn + "\n"
return "[≡ " + root + " ≡] " + turn + "\n"
}

// diffHandoffChain renders the submodule hand-off lines beneath a turn banner:
Expand Down
5 changes: 5 additions & 0 deletions pkg/action/diff_header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,9 @@ func TestDiffCollector_BannerOncePerTurnHandoffPerSubmodule(t *testing.T) {
t.Errorf("expected hand-off %q, got:\n%s", want, out)
}
}
// Every header block is set off from the diff above it by a blank line, so a
// breadcrumb between two diffs stays visible — the within-turn submodule too.
if !strings.Contains(out, "\n\n▸ deploy-1 › ingress") {
t.Errorf("expected a blank line before the within-turn submodule header, got:\n%s", out)
}
}
Loading