|
68 | 68 |
|
69 | 69 | merge_methods=("merge" "squash" "rebase") |
70 | 70 |
|
| 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 | + |
71 | 108 | # Check for flags and valued options |
72 | 109 | dry_run=false |
73 | 110 | bump_patch_version=false |
74 | 111 | enable_auto_merge=false |
75 | 112 | no_prompt=false |
76 | 113 | search_owner="" |
77 | 114 | 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") |
79 | 116 | args=("$@") |
80 | 117 | i=0 |
81 | 118 | while [ $i -lt ${#args[@]} ]; do |
82 | 119 | 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 |
84 | 124 | dry_run=true |
85 | 125 | elif [ "$arg" = "--bump-patch-version" ]; then |
86 | 126 | bump_patch_version=true |
@@ -116,24 +156,7 @@ while [ $i -lt ${#args[@]} ]; do |
116 | 156 | done |
117 | 157 |
|
118 | 158 | 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 |
137 | 160 | exit 1 |
138 | 161 | fi |
139 | 162 |
|
|
0 commit comments