fix(scripts): match both (#X) and [#X] PR-number forms in generate-changelog.sh#26
Merged
Merged
Conversation
…e-changelog.sh The PR-number extraction regex `\(#\K\d+` only matches the parenthesized form git-cliff emits on the initial prepend. The script's own Python step rewrites those into markdown-link form `[#14](https://github.com/...)`, so a second run (e.g. `--dry-run` against an already-processed CHANGELOG.md, which is exactly the sync-dev-after-release.sh regen- idempotency check's mode of operation) extracts zero PR numbers. With `set -euo pipefail`, the grep's exit-1-on-no-match aborts the whole script before reaching `summarize_and_exit`, producing empty output and a misleading non-zero exit code. Surfaced during the v0.5.0 release backport: the new regen-idempotency check warned "PR bodies have drifted" with no diff body. Root cause was the regex, not real drift. Fix: - Match both forms: `[\(\[]#\K\d+` accepts `(#14)` from git-cliff and `[#14]` from the rewritten link. - Append `|| true` so the pipeline exit status survives the empty-match case and the downstream `[[ -z "$PR_NUMBERS" ]]` branch can handle it cleanly via `summarize_and_exit`. Known follow-up (NOT in this PR): the dry-run comparison uses byte-exact `cmp -s`. The on-disk CHANGELOG.md is line-wrapped by the repo's markdownlint / md-wrap hook; the script's direct writes are unwrapped. Even after this fix, the dry-run will report false-positive "drift" on every release until the comparison is made wrap-tolerant (paragraph unwrap then diff). The check is "warn, do not fail" so this does not block; tracked in the sibling-repo plans and to be fixed alongside the broader sync-script port.
brettdavies
added a commit
to brettdavies/agentnative
that referenced
this pull request
Jun 1, 2026
Folds two new items into the existing P0 mirror plan: (A) the PR-number extraction regex fix shipped in brettdavies/agentnative-skill PR #26 — `\(#\K\d+` only matches git-cliff's `(#X)` form, not the markdown-link `[#X](…)` form the script's Python expansion rewrites those to, causing `set -euo pipefail` to abort a second run with empty output; and (B) the known follow-up the skill PR did not ship, where the dry-run's byte-exact `cmp -s` false-positives "drift" against a wrap-tolerant on-disk `CHANGELOG.md` until the comparison is paragraph-flattened. Reference PR: brettdavies/agentnative-skill#26
brettdavies
added a commit
to brettdavies/agentnative-cli
that referenced
this pull request
Jun 1, 2026
Expands the existing P0 mirror plan from three items to five by adding the two `generate-changelog.sh` fixes surfaced after the original PR #25 mirror was written: (A) the PR-number extraction regex fix shipped in brettdavies/agentnative-skill PR #26 — `\(#\K\d+` only matches git-cliff's `(#X)` form, not the markdown-link `[#X](…)` form the script's Python expansion rewrites those to, causing `set -euo pipefail` to abort a second run (i.e. the `sync-dev-after-release.sh` regen-idempotency check, item 2 in this plan) with empty output; and (B) the known follow-up the skill PR did not ship, where the dry-run's byte-exact `cmp -s` false-positives "drift" against a wrap-tolerant on-disk `CHANGELOG.md` until the comparison is paragraph-flattened. Without item B, the regen-idempotency warning fires on every release regardless of real drift. Reference PR: brettdavies/agentnative-skill#26
brettdavies
added a commit
to brettdavies/agentnative-site
that referenced
this pull request
Jun 1, 2026
Folds two additional items into the step-2 port list of the existing P0 applicability-evaluation plan, conditional on the same "if `generate-changelog.sh` lands here" gate as the rest of the step: (A) the PR-number extraction regex fix shipped in brettdavies/agentnative-skill PR #26 — `\(#\K\d+` only matches git-cliff's `(#X)` form, not the markdown-link `[#X](…)` form the script's Python expansion rewrites those to, causing `set -euo pipefail` to abort a second run with empty output; and (B) the known follow-up the skill PR did not ship, where the dry-run's byte-exact `cmp -s` false-positives "drift" against a wrap-tolerant on-disk `CHANGELOG.md` until the comparison is paragraph-flattened. Items 5 and 6 (the sync-script preconditions) are the consumers that make items 3 and 4 matter, so the dependencies between the four ported items are now spelled out in the plan. Reference PR: brettdavies/agentnative-skill#26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The PR-number extraction regex in
scripts/generate-changelog.shwas\(#\K\d+, which only matches the parenthesized form git-cliff emits on the initial prepend. The script's own Python step rewrites those into markdown-link form[#14](https://github.com/.../pull/14). A second run (e.g.--dry-runagainst an already-processed CHANGELOG.md, which is exactly thesync-dev-after-release.shregen-idempotency check's mode of operation) extracts zero PR numbers.Combined with
set -euo pipefail, grep's exit-1-on-no-match aborts the whole script beforesummarize_and_exitcan run, producing empty output and an opaque non-zero exit code.Surfaced during the v0.5.0 release backport. The new regen-idempotency check warned "PR bodies have drifted" with no diff body. Root cause was the regex, not real drift.
Fix:
[\(\[]#\K\d+accepts both(#14)from git-cliff and[#14]from the rewritten link.|| truelets the pipeline exit status survive the empty-match case so the downstream[[ -z "$PR_NUMBERS" ]]branch handles it cleanly via
summarize_and_exit.Known follow-up (not in this PR)
The dry-run comparison uses byte-exact
cmp -s. The on-diskCHANGELOG.mdis line-wrapped by the repo'smarkdownlint /
md-wraphook; the script's direct writes are unwrapped. Even after this fix, the dry-run willfalse-positive "drift" on every release until the comparison is made wrap-tolerant (paragraph-unwrap then diff). The
check is "warn, do not fail" so this does not block. Tracked in the sibling-repo plans and to be fixed alongside the
broader sync-script port.
Changelog
Fixed
scripts/generate-changelog.sh: PR-number extraction now matches both(#X)(git-cliff initial prepend) and[#X](markdown-link form written by the Python expansion step). Re-runs and--dry-runno longer abort with empty output on an already-processedCHANGELOG.md.Type of Change
fix: Bug fix (non-breaking change which fixes an issue)Files Modified
Modified:
scripts/generate-changelog.shBreaking Changes
Deployment Notes
Checklist