mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-09 22:48:57 +02:00
fix(pr-title): stop duplicating the version prefix on bare-version titles
A title that was nothing but a version ("v1.2.3" — the form ship uses for
version-only bumps) matched neither the "v<NEW_VERSION> " literal case nor
the trailing-space strip regex, fell through to the prepend path, and came
out as "v1.2.3.4 v1.2.3" — which pr-title-sync.yml then wrote back via
gh pr edit. Handle the bare form in both the no-change case and the
prefix-strip regex, and emit a bare new version when nothing follows.
Closes #1886.
Contributed by @jbetala7 (PR #1887).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
85ab953cc9
commit
3853cd470d
@@ -24,6 +24,23 @@ describe('gstack-pr-title-rewrite', () => {
|
||||
expect(rewrite('1.2.3.4', 'v1.2.3 feat: foo').stdout).toBe('v1.2.3.4 feat: foo');
|
||||
});
|
||||
|
||||
test('bare correct version (no description): no change, not duplicated', () => {
|
||||
// CHANGELOG/ship uses a version-only title for branch-ahead bumps. It must
|
||||
// stay as-is, not become "v1.2.3.4 v1.2.3.4".
|
||||
expect(rewrite('1.2.3.4', 'v1.2.3.4').stdout).toBe('v1.2.3.4');
|
||||
});
|
||||
|
||||
test('bare different version (no description): replaces, not duplicates', () => {
|
||||
// Must strip the stale prefix even with nothing after it, otherwise CI
|
||||
// writes back "v1.2.3.4 v1.2.3".
|
||||
expect(rewrite('1.2.3.4', 'v1.2.3').stdout).toBe('v1.2.3.4');
|
||||
});
|
||||
|
||||
test('idempotent on a bare version title', () => {
|
||||
const once = rewrite('1.2.3.4', 'v1.2.3').stdout;
|
||||
expect(rewrite('1.2.3.4', once).stdout).toBe(once);
|
||||
});
|
||||
|
||||
test('no version prefix: prepends', () => {
|
||||
expect(rewrite('1.2.3.4', 'feat: foo').stdout).toBe('v1.2.3.4 feat: foo');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user