From efdff9c738f7dcf42fc99b7fe4d071ab73cccf03 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 8 Mar 2026 00:23:34 +0000 Subject: [PATCH] fix(scripts): enforce changelog.md and post clickable SHA links --- scripts/pr | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/scripts/pr b/scripts/pr index 93e312f40..4dcac6424 100755 --- a/scripts/pr +++ b/scripts/pr @@ -1272,27 +1272,14 @@ prepare_gates() { if printf '%s\n' "$changed_files" | rg -q '^CHANGELOG\.md$'; then has_changelog_update=true fi - local fragment_files - fragment_files=$(changed_changelog_fragment_files) - local has_fragment_update=false - if [ -n "$fragment_files" ]; then - has_fragment_update=true - fi - # Enforce workflow policy: every prepared PR must include either CHANGELOG.md - # or one or more changelog fragments. - if [ "$has_changelog_update" = "false" ] && [ "$has_fragment_update" = "false" ]; then - echo "Missing changelog update. Add CHANGELOG.md changes or changelog/fragments/*.md entry." + # Enforce workflow policy: every prepared PR must include CHANGELOG.md. + if [ "$has_changelog_update" = "false" ]; then + echo "Missing changelog update. Add CHANGELOG.md changes." exit 1 fi local contrib="${PR_AUTHOR:-}" - if [ "$has_changelog_update" = "true" ]; then - validate_changelog_merge_hygiene - validate_changelog_entry_for_pr "$pr" "$contrib" - fi - if [ "$has_fragment_update" = "true" ]; then - mapfile -t fragment_file_list <<<"$fragment_files" - validate_changelog_fragments_for_pr "$pr" "$contrib" "${fragment_file_list[@]}" - fi + validate_changelog_merge_hygiene + validate_changelog_entry_for_pr "$pr" "$contrib" run_quiet_logged "pnpm build" ".local/gates-build.log" pnpm build run_quiet_logged "pnpm check" ".local/gates-check.log" pnpm check @@ -1934,6 +1921,31 @@ EOF_BODY echo "Merge commit SHA missing." exit 1 fi + local repo_nwo + repo_nwo=$(gh repo view --json nameWithOwner --jq .nameWithOwner) + + local merge_sha_url="" + if gh api repos/:owner/:repo/commits/"$merge_sha" >/dev/null 2>&1; then + merge_sha_url="https://github.com/$repo_nwo/commit/$merge_sha" + else + echo "Merge commit is not resolvable via repository commit endpoint: $merge_sha" + exit 1 + fi + + local prep_sha_url="" + if gh api repos/:owner/:repo/commits/"$PREP_HEAD_SHA" >/dev/null 2>&1; then + prep_sha_url="https://github.com/$repo_nwo/commit/$PREP_HEAD_SHA" + else + local pr_commit_count + pr_commit_count=$(gh pr view "$pr" --json commits --jq "[.commits[].oid | select(. == \"$PREP_HEAD_SHA\")] | length") + if [ "${pr_commit_count:-0}" -gt 0 ]; then + prep_sha_url="https://github.com/$repo_nwo/pull/$pr/commits/$PREP_HEAD_SHA" + fi + fi + if [ -z "$prep_sha_url" ]; then + echo "Prepared head SHA is not resolvable in repo commits or PR commit list: $PREP_HEAD_SHA" + exit 1 + fi local commit_body commit_body=$(gh api repos/:owner/:repo/commits/"$merge_sha" --jq .commit.message) @@ -1947,8 +1959,8 @@ EOF_BODY if comment_output=$(gh pr comment "$pr" -F - 2>&1 <