Skip to content

Commit 9654f43

Browse files
fix(changelog): detect changes via --fail-on=INFO exit code, not json parsing
Replace the json-render "[]" probe with oasdiff's own changes-present signal: run changelog with --fail-on=INFO and read the exit code (1 = at least one change at or above --level, 0 = empty). This is format-proof by construction (no output parsing) and is the canonical "are there changes" check. --level stays in the probe so detection matches what the user sees; the explicit --fail-on overrides any config fail-on for the probe only, and the user-facing render is untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5944c0d commit 9654f43

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

changelog/entrypoint.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ if [ -n "$level" ]; then
153153
flags="$flags --level $level"
154154
fi
155155
# format and template are presentation-only. Keep them out of $flags so the
156-
# json change-probe and the --open upload below run on the semantic flags only:
157-
# the probe must render as json regardless of the user's format, and --template
158-
# is rejected for json (it would error both). $fmt_flags is applied only to the
159-
# user-facing changelog render.
156+
# changes probe and the --open upload below run on the semantic flags only: the
157+
# probe doesn't need the user's format, and --open renders the changelog as json
158+
# internally where --template is rejected (it would error the upload). $fmt_flags
159+
# is applied only to the user-facing changelog render.
160160
fmt_flags=""
161161
if [ -n "$format" ]; then
162162
fmt_flags="$fmt_flags --format $format"
@@ -197,14 +197,15 @@ fi
197197
rm -f "$_err"
198198

199199
# Decide whether there are changes independently of --format. The user-facing
200-
# $output may be json/yaml ("[]") or markup (a header line then "No changes
201-
# detected"), none of which the old first-line "^No " test caught, so a
202-
# non-default format spammed clean PRs with a review link. A json render is
203-
# unambiguous: an empty changelog is "[]". Probe with the semantic flags only
204-
# (level included, so detection matches what the user sees). The probe is a
205-
# local diff identical to the run above, so it fails only when that run would.
206-
changes_json=$(oasdiff changelog "$base" "$revision" $flags --format json 2>/dev/null | tr -d '[:space:]') || changes_json=""
207-
if [ -n "$changes_json" ] && [ "$changes_json" != "[]" ]; then
200+
# $output varies by format (json/yaml render "[]", markup adds a header line), so
201+
# parsing it is fragile. Instead read oasdiff's exit code with --fail-on=INFO:
202+
# exit 1 means the changelog has at least one change at or above --level, exit 0
203+
# means it's empty. --level stays in $flags so detection matches what the user
204+
# sees; the explicit --fail-on overrides any config fail-on for this probe only,
205+
# and the rendered run above is untouched.
206+
changes_exit=0
207+
oasdiff changelog "$base" "$revision" $flags --fail-on=INFO >/dev/null 2>&1 || changes_exit=$?
208+
if [ "$changes_exit" -eq 1 ]; then
208209
write_output "$output"
209210

210211
free_review_url=""

0 commit comments

Comments
 (0)