Skip to content

Commit 18c5c77

Browse files
feat(help): add detailed usage instructions and help flag to merge-pull-requests-by-title.sh (#164)
* feat(help): add detailed usage instructions and help flag to merge-pull-requests-by-title.sh * fix(gh-cli): clarify --bump-patch-version does not merge alone Update help text to note that --bump-patch-version only bumps/commits/pushes and does not merge PRs unless combined with --enable-auto-merge.
1 parent 97e2780 commit 18c5c77

1 file changed

Lines changed: 43 additions & 20 deletions

File tree

gh-cli/merge-pull-requests-by-title.sh

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,59 @@
6868

6969
merge_methods=("merge" "squash" "rebase")
7070

71+
print_help() {
72+
echo "Find and merge pull requests matching a title pattern across multiple repositories"
73+
echo ""
74+
echo "Usage:"
75+
echo " $0 <repo_list_file> <pr_title_pattern> [merge_method] [commit_title] [flags...]"
76+
echo " $0 --owner <owner> <pr_title_pattern> [--topic <topic>]... [merge_method] [commit_title] [flags...]"
77+
echo ""
78+
echo "Required (one of):"
79+
echo " repo_list_file - File with repository URLs (one per line)"
80+
echo " --owner <owner> - Search repositories for this user or organization"
81+
echo ""
82+
echo "Required:"
83+
echo " pr_title_pattern - Title pattern to match (exact match or use * for wildcard)"
84+
echo ""
85+
echo "Optional positional arguments:"
86+
echo " merge_method - Merge method: merge, squash, or rebase (default: squash)"
87+
echo " commit_title - Custom commit title for merged PRs (PR number is auto-appended; defaults to PR title)"
88+
echo ""
89+
echo "Flags:"
90+
echo " -h, --help - Show this help message and exit"
91+
echo " --topic <topic> - Filter --owner repositories by topic (can be specified multiple times)"
92+
echo " --dry-run - Preview what would be merged without actually merging"
93+
echo " --bump-patch-version - Clone each matching PR branch, run npm version patch, commit, and push (does not merge; use with --enable-auto-merge to also merge)"
94+
echo " --enable-auto-merge - Enable auto-merge on matching PRs"
95+
echo " --no-prompt - Merge without interactive confirmation"
96+
echo ""
97+
echo "Flag compatibility:"
98+
echo " --dry-run and --bump-patch-version are mutually exclusive"
99+
echo " --dry-run and --enable-auto-merge are mutually exclusive"
100+
echo " --topic requires --owner"
101+
echo ""
102+
echo "Examples:"
103+
echo " $0 repos.txt \"chore(deps)*\" --dry-run"
104+
echo " $0 repos.txt \"chore(deps)*\" --bump-patch-version --enable-auto-merge"
105+
echo " $0 --owner joshjohanning --topic github-action \"chore(deps)*\" --no-prompt"
106+
}
107+
71108
# Check for flags and valued options
72109
dry_run=false
73110
bump_patch_version=false
74111
enable_auto_merge=false
75112
no_prompt=false
76113
search_owner=""
77114
topics=()
78-
valid_flags=("--dry-run" "--bump-patch-version" "--enable-auto-merge" "--no-prompt" "--owner" "--topic")
115+
valid_flags=("-h" "--help" "--dry-run" "--bump-patch-version" "--enable-auto-merge" "--no-prompt" "--owner" "--topic")
79116
args=("$@")
80117
i=0
81118
while [ $i -lt ${#args[@]} ]; do
82119
arg="${args[$i]}"
83-
if [ "$arg" = "--dry-run" ]; then
120+
if [ "$arg" = "--help" ] || [ "$arg" = "-h" ]; then
121+
print_help
122+
exit 0
123+
elif [ "$arg" = "--dry-run" ]; then
84124
dry_run=true
85125
elif [ "$arg" = "--bump-patch-version" ]; then
86126
bump_patch_version=true
@@ -116,24 +156,7 @@ while [ $i -lt ${#args[@]} ]; do
116156
done
117157

118158
if [ $# -lt 2 ]; then
119-
echo "Usage: $0 <repo_list_file> <pr_title_pattern> [merge_method] [commit_title] [flags...]"
120-
echo " $0 --owner <owner> <pr_title_pattern> [--topic <topic>]... [merge_method] [commit_title] [flags...]"
121-
echo ""
122-
echo "Required (one of):"
123-
echo " repo_list_file - File with repository URLs (one per line)"
124-
echo " --owner <owner> - Search repositories for this user or organization"
125-
echo ""
126-
echo "Required:"
127-
echo " pr_title_pattern - Title pattern to match (use * for wildcard)"
128-
echo ""
129-
echo "Optional:"
130-
echo " merge_method - merge, squash, or rebase (default: squash)"
131-
echo " commit_title - Custom commit title for merged PRs (defaults to PR title)"
132-
echo " --topic <topic> - Filter --owner repositories by topic (repeatable)"
133-
echo " --dry-run - Preview what would be merged (cannot combine with --bump-patch-version or --enable-auto-merge)"
134-
echo " --bump-patch-version - Bump npm patch version on each matching PR branch and push (cannot combine with --dry-run)"
135-
echo " --enable-auto-merge - Enable auto-merge on matching PRs (can combine with --bump-patch-version, cannot combine with --dry-run)"
136-
echo " --no-prompt - Merge without interactive confirmation"
159+
print_help
137160
exit 1
138161
fi
139162

0 commit comments

Comments
 (0)