Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions gh-cli/merge-pull-requests-by-title.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Comment thread
joshjohanning marked this conversation as resolved.
fi

# Attempt to merge
Expand Down
19 changes: 11 additions & 8 deletions gh-cli/merge-pull-requests-from-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)")
Comment thread
joshjohanning marked this conversation as resolved.
fi

# Apply custom commit body with template substitution
Expand Down