From bd1c35c3c8a0f1b889a040b539f858d18344a31d Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Mon, 26 Jan 2026 16:46:20 -0600 Subject: [PATCH 1/2] feat: include PR number in commit subject for merge scripts --- gh-cli/merge-pull-requests-by-title.sh | 10 +++++++--- gh-cli/merge-pull-requests-from-list.sh | 14 +++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gh-cli/merge-pull-requests-by-title.sh b/gh-cli/merge-pull-requests-by-title.sh index b6bdd1c..eeb01f7 100755 --- a/gh-cli/merge-pull-requests-by-title.sh +++ b/gh-cli/merge-pull-requests-by-title.sh @@ -153,9 +153,13 @@ while IFS= read -r repo_url || [ -n "$repo_url" ]; do # Build the merge command merge_args=("--$merge_method") - # Apply custom commit title if provided - if [ -n "$commit_title" ] && [ "$merge_method" != "rebase" ]; then - merge_args+=("--subject" "$commit_title") + # Always include PR number in commit subject (e.g., "commit message (#123)") + if [ "$merge_method" != "rebase" ]; then + if [ -n "$commit_title" ]; then + merge_args+=("--subject" "$commit_title (#$pr_number)") + else + merge_args+=("--subject" "$pr_title (#$pr_number)") + fi fi # Attempt to merge diff --git a/gh-cli/merge-pull-requests-from-list.sh b/gh-cli/merge-pull-requests-from-list.sh index 43449fb..1a80db0 100755 --- a/gh-cli/merge-pull-requests-from-list.sh +++ b/gh-cli/merge-pull-requests-from-list.sh @@ -151,11 +151,15 @@ while IFS= read -r pr_url || [ -n "$pr_url" ]; do # Build the merge command merge_args=("--$merge_method") - # Apply custom commit title with template substitution - if [ -n "$commit_title" ] && [ "$merge_method" != "rebase" ]; then - final_title="${commit_title//\{title\}/$pr_title}" - final_title="${final_title//\{number\}/$pr_number}" - merge_args+=("--subject" "$final_title") + # Always include PR number in commit subject (e.g., "commit message (#123)") + if [ "$merge_method" != "rebase" ]; then + if [ -n "$commit_title" ]; then + final_title="${commit_title//\{title\}/$pr_title}" + final_title="${final_title//\{number\}/$pr_number}" + else + final_title="$pr_title" + fi + merge_args+=("--subject" "$final_title (#$pr_number)") fi # Apply custom commit body with template substitution From 1fe159c308ea009ce26c8ea44021ffb9ac18c65c Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Mon, 26 Jan 2026 16:56:17 -0600 Subject: [PATCH 2/2] docs: update commit_title and commit_body descriptions to clarify PR number appending --- gh-cli/merge-pull-requests-by-title.sh | 4 ++-- gh-cli/merge-pull-requests-from-list.sh | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gh-cli/merge-pull-requests-by-title.sh b/gh-cli/merge-pull-requests-by-title.sh index eeb01f7..c99920b 100755 --- a/gh-cli/merge-pull-requests-by-title.sh +++ b/gh-cli/merge-pull-requests-by-title.sh @@ -9,7 +9,7 @@ # repo_list_file - File with repository URLs (one per line) # pr_title_pattern - Title pattern to match (exact match or use * for wildcard) # merge_method - Optional: merge method (merge, squash, rebase) - defaults to squash -# commit_title - Optional: custom commit title for all merged PRs +# commit_title - Optional: custom commit title for all merged PRs (PR number is auto-appended) # --dry-run - Optional: preview what would be merged without actually merging # # Examples: @@ -54,7 +54,7 @@ if [ $# -lt 2 ]; then echo " repo_list_file - File with repository URLs (one per line)" echo " pr_title_pattern - Title pattern to match (use * for wildcard)" echo " merge_method - Optional: merge, squash, or rebase (default: squash)" - echo " commit_title - Optional: custom commit title for merged PRs" + echo " commit_title - Optional: custom commit title for merged PRs (PR number is auto-appended)" echo " --dry-run - Preview what would be merged without actually merging" exit 1 fi diff --git a/gh-cli/merge-pull-requests-from-list.sh b/gh-cli/merge-pull-requests-from-list.sh index 1a80db0..4043a6a 100755 --- a/gh-cli/merge-pull-requests-from-list.sh +++ b/gh-cli/merge-pull-requests-from-list.sh @@ -8,8 +8,8 @@ # Arguments: # pr_list_file - File with PR URLs (one per line) # merge_method - Optional: merge method (merge, squash, rebase) - defaults to squash -# commit_title - Optional: custom commit title (use {title} for original PR title, {number} for PR number) -# commit_body - Optional: custom commit body (use {body} for original PR body) +# commit_title - Optional: custom commit title (use {title} for original PR title; PR number is auto-appended) +# commit_body - Optional: custom commit body (use {body} for original PR body, {title} for PR title) # --dry-run - Optional: preview what would be merged without actually merging # # Examples: @@ -61,7 +61,7 @@ if [ $# -lt 1 ]; then echo "Arguments:" echo " pr_list_file - File with PR URLs (one per line)" echo " merge_method - Optional: merge, squash, or rebase (default: squash)" - echo " commit_title - Optional: custom commit title (use {title} for PR title, {number} for PR number)" + echo " commit_title - Optional: custom commit title (use {title} for PR title; PR number is auto-appended)" echo " commit_body - Optional: custom commit body (use {body} for PR body)" echo " --dry-run - Preview what would be merged without actually merging" exit 1 @@ -155,7 +155,6 @@ while IFS= read -r pr_url || [ -n "$pr_url" ]; do if [ "$merge_method" != "rebase" ]; then if [ -n "$commit_title" ]; then final_title="${commit_title//\{title\}/$pr_title}" - final_title="${final_title//\{number\}/$pr_number}" else final_title="$pr_title" fi