diff --git a/gh-cli/merge-pull-requests-by-title.sh b/gh-cli/merge-pull-requests-by-title.sh index b6bdd1c..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 @@ -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..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 @@ -151,11 +151,14 @@ 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}" + else + final_title="$pr_title" + fi + merge_args+=("--subject" "$final_title (#$pr_number)") fi # Apply custom commit body with template substitution