mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 03:35:09 +02:00
7efa85cb4f
* feat: add bin/gstack-pr-title-rewrite.sh shared helper Single source of truth for "rewrite a PR title to start with v<VERSION>". Three cases: already correct (no-op), different prefix (replace), no prefix (prepend). Rejects malformed VERSION (anything outside ^[0-9]+(\.[0-9]+)*$) with exit code 2. Uses literal case prefix match instead of bash's pattern- matching # operator so a VERSION with glob metacharacters cannot mismatch. Free bun test covers the four branches plus malformed-input rejection, plain-words-not-stripped, single-segment-not-stripped, idempotence, and missing-args. 9 tests, ~400ms. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(skills): /ship and /document-release always prefix PR titles with v<VERSION> ship/SKILL.md.tmpl Step 19: idempotency block now always rewrites titles to start with v$NEW_VERSION via the new helper. Removes the "custom title kept intentionally" loophole that let unprefixed titles persist forever. Adds a post-edit self-check that re-fetches the title and retries once if the edit didn't stick. Inline comments on the create-PR snippets at lines 867 and 876 make the rule unmissable. document-release/SKILL.md.tmpl Step 9: new "PR/MR title sync" sub-step calls the same helper after the body update. Catches the case where Step 8 bumped VERSION after /ship had already created the PR — title now follows VERSION instead of going stale. Golden fixtures regenerated for claude/codex/factory ship variants. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(ci): pr-title-sync rewrites titles unconditionally Drops the "eligible only if already prefixed" gate. Sources the new shared helper, rewrites unconditionally on every VERSION change. Defense-in-depth backstop for PRs opened outside the skills (manual gh pr create, web UI). Uses env: for OLD_TITLE so YAML expression injection cannot reach run:. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * chore: bump version and changelog (v1.23.0.0) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
45 lines
1.4 KiB
Bash
Executable File
45 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Rewrite a PR/MR title to start with v<NEW_VERSION>.
|
|
#
|
|
# Usage: bin/gstack-pr-title-rewrite.sh <NEW_VERSION> <CURRENT_TITLE>
|
|
# Output: corrected title on stdout.
|
|
#
|
|
# Rule: PR titles MUST start with v<NEW_VERSION>. Three cases:
|
|
# 1. Already starts with "v<NEW_VERSION> " -> no change.
|
|
# 2. Starts with a different "v<digits and dots> " prefix -> replace prefix.
|
|
# 3. No version prefix -> prepend "v<NEW_VERSION> ".
|
|
#
|
|
# The version-prefix regex matches two or more dot-separated digit segments
|
|
# (covers v1.2, v1.2.3, v1.2.3.4) so the rule is portable across repos that
|
|
# use 3-part or 4-part versions, but does NOT strip plain words like
|
|
# "version 5".
|
|
|
|
set -euo pipefail
|
|
|
|
if [ $# -lt 2 ]; then
|
|
echo "usage: $0 <NEW_VERSION> <CURRENT_TITLE>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
NEW_VERSION="$1"
|
|
TITLE="$2"
|
|
|
|
# Reject malformed NEW_VERSION early. Real values are dot-separated digits;
|
|
# anything with shell pattern metacharacters or whitespace is a caller bug.
|
|
if ! printf '%s' "$NEW_VERSION" | grep -qE '^[0-9]+(\.[0-9]+)*$'; then
|
|
echo "error: NEW_VERSION must be dot-separated digits, got: $NEW_VERSION" >&2
|
|
exit 2
|
|
fi
|
|
|
|
# Literal prefix match (case statement is glob-quoted by bash, but our
|
|
# regex-validated NEW_VERSION has no glob metacharacters so this is safe).
|
|
case "$TITLE" in
|
|
"v$NEW_VERSION "*)
|
|
printf '%s\n' "$TITLE"
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
REST=$(printf '%s' "$TITLE" | sed -E 's/^v[0-9]+(\.[0-9]+)+ //')
|
|
printf 'v%s %s\n' "$NEW_VERSION" "$REST"
|