From 481b5376af8b54f02829c5f77a09981bd26e47bf Mon Sep 17 00:00:00 2001 From: Lucas Weatherhog <31103312+weatherhog@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:49:32 +0200 Subject: [PATCH] feat(yaml-diff): colourise diff output via ```diff fenced block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub PR comments can't render ANSI, so colour the semantic diff using the `diff` code-fence highlighter instead: switch the fence to ```diff, move dyff's indented go-patch `-`/`+` markers to column 0 (keeping the indent after the marker) so removed/added values render red/green, and emit each file header as `@@ @@` for a coloured separator. The sed rewrite only reorders leading whitespace, so byte counts — and the per-file/total truncation caps computed earlier — are unchanged. dyff's own colour stays off (auto-off in CI); we rely purely on GitHub's syntax highlighting. Requested in giantswarm/roadmap#4121. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/yaml-diff.yaml | 13 ++++++++++--- CHANGELOG.md | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/yaml-diff.yaml b/.github/workflows/yaml-diff.yaml index 6119271..747f2cc 100644 --- a/.github/workflows/yaml-diff.yaml +++ b/.github/workflows/yaml-diff.yaml @@ -188,7 +188,7 @@ jobs: section=$(mktemp) { echo - echo "=== ${path} ===" + echo "@@ ${path} @@" cat /tmp/yaml-diff/file-diff } > "${section}" @@ -227,8 +227,15 @@ jobs: echo "Output" echo "" echo - echo '```' - cat /tmp/yaml-diff/body + echo '```diff' + # GitHub colours a `diff` fence by line prefix: `-` red, `+` green, + # `@@ … @@` header. dyff go-patch prefixes changed values with an + # *indented* `-`/`+`; move the marker to column 0 while keeping the + # original indent *after* it, so the highlighter fires and nesting is + # still visible. The rewrite only reorders leading whitespace, so byte + # counts (and the truncation maths above) are unchanged. dyff colour + # stays off (auto-off in CI) — comments cannot render ANSI. + sed -E 's/^([[:space:]]*)([+-])([[:space:]].*)$/\2\1\3/' /tmp/yaml-diff/body echo '```' echo "" echo "" diff --git a/CHANGELOG.md b/CHANGELOG.md index f62d6cc..b389716 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), however this project does not use Semantic Versioning and there are no releases. Instead this file uses a date-based structure. +## 2026-07-02 + +### Changed + +- `yaml-diff.yaml` now posts its `dyff` output inside a ` ```diff ` fenced block so GitHub colourises it — removed values render red, added values green, and each file gets a `@@ … @@` header. dyff's go-patch `-`/`+` markers are moved to column 0 (indentation preserved after the marker) so the highlighter picks them up; the rewrite only reorders leading whitespace, so the comment-size truncation limits are unaffected. dyff's own ANSI colour stays disabled (comments can't render it). Requested in giantswarm/roadmap#4121. + ## 2026-06-30 ### Fixed