fix(pr-title): don't duplicate the version prefix on bare-version PR titles#1887
Open
jbetala7 wants to merge 1 commit into
Open
fix(pr-title): don't duplicate the version prefix on bare-version PR titles#1887jbetala7 wants to merge 1 commit into
jbetala7 wants to merge 1 commit into
Conversation
gstack-pr-title-rewrite.sh anchored both its no-change case match
("v$NEW_VERSION "*) and its prefix-strip sed (/^v…+ /) on a trailing
space, so a title that is a bare version with no description fell through
to the prepend case and got a second prefix:
v1.2.3.4 + "v1.2.3.4" -> "v1.2.3.4 v1.2.3.4" (should be no change)
v1.2.3.4 + "v1.2.3" -> "v1.2.3.4 v1.2.3" (stale prefix kept)
This violated the helper's documented case 1 (no change) and case 2
(replace prefix) and its idempotency contract. It is reachable in CI:
.github/workflows/pr-title-sync.yml feeds the real PR title through the
helper and then `gh pr edit`s the result, so a version-only PR title (the
format ship/CHANGELOG uses for branch-ahead bumps) gets corrupted, and it
never self-heals (the duplicated form then matches case 1).
Match the bare "v$NEW_VERSION" form in the no-change case, strip an
existing prefix at a space OR end-of-string, and emit a bare new prefix
when the title had no description. Adds 3 regression tests (bare correct,
bare different, bare idempotency) that fail on main and pass with the fix.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
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.
Problem
bin/gstack-pr-title-rewrite.shduplicates the version prefix when a PR title is a bare version with no description:Root cause
Both the no-change
caseglob ("v$NEW_VERSION "*) and the stripsed(s/^v[0-9]+(\.[0-9]+)+ //) anchor on a trailing space. A title that is only a version (nothing after) matches neither, so it falls through to the prepend case and gets a second prefix. It also never self-heals — once it becomesv1.2.3.4 v1.2.3.4, the duplicated form matches case 1 and is returned as-is.This is reachable in CI:
.github/workflows/pr-title-sync.ymlruns on every PR open/edit/synchronize, feeds the real title through this helper, andgh pr edits the result. A version-only PR title (the format ship/CHANGELOG uses for branch-ahead bumps) gets rewritten to the duplicated form and written back to the PR.Fix
"v$NEW_VERSION"form in the no-changecase.( |$)).All three documented cases (no-change / replace / prepend) now hold for both
v1.2.3 <desc>and barev1.2.3titles. Titles with descriptions, theversion 5non-prefix guard, and the single-segmentv1guard are unchanged.Testing
bun test test/pr-title-rewrite.test.ts— 12 pass (9 existing + 3 new).The 3 new tests (bare-correct -> no change, bare-different -> replace, bare idempotency) were verified to fail on
mainbefore the fix:bash -nclean,git diff --checkclean,slop:diffadds no findings in the changed files.Fixes #1886