|
47 | 47 | # Check the arguments |
48 | 48 | if [ -z ${prId} ]; then |
49 | 49 | echo "Usage: git pr pool-request-number [ --force ]" |
| 50 | + echo "Works for any Apache repository mirrored on GitHub'" |
50 | 51 | echo "For instructions, see: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61311655" |
51 | 52 | clean_up_and_exit 1 |
52 | 53 | fi |
53 | 54 |
|
54 | 55 | # Vars we need |
55 | 56 | jsonTmp="${PWD}/${prId}.json" |
56 | 57 | tmpMessageFile="${PWD}/.git-tmp-message.txt" |
| 58 | +repoName=$(basename `git rev-parse --show-toplevel`) |
57 | 59 |
|
58 | 60 | # We need UTF-8 to support the GitHub '...' 3-dots-in-1-char, for example. |
59 | 61 | export LANG="en_EN.UTF-8" |
60 | 62 |
|
61 | 63 | if [ "${prId}" -eq "${prId}" 2>/dev/null ]; then |
62 | 64 | # Get json data from Github API |
63 | | - curl -s https://api.github.com/repos/apache/cloudstack/pulls/${prId} > ${jsonTmp} |
| 65 | + curl -s https://api.github.com/repos/apache/${repoName}/pulls/${prId} > ${jsonTmp} |
64 | 66 | else |
65 | 67 | echo "ERROR: Pull-request id must be an integer, not '${prId}'" |
66 | 68 | clean_up_and_exit 1 |
@@ -176,23 +178,23 @@ elif [ "${prMergeableState}" != "clean" ] && [ ${force} -eq 1 ]; then |
176 | 178 | echo "WARNING: You used --force to merge a PR with non-clean merge state '${prMergeableState}'." |
177 | 179 | fi |
178 | 180 |
|
179 | | -github_remote=$(git remote -v | grep "apache/cloudstack.git" | head -n 1 | cut -f1) |
| 181 | +github_remote=$(git remote -v | grep -E "apache/${repoName}(.git)?" | head -n 1 | cut -f1) |
180 | 182 | if [ ${#github_remote} -eq 0 ]; then |
181 | | - echo "ERROR: We couldn't find a git remote pointing to 'apache/cloudstack.git' to merge the PR from." |
| 183 | + echo "ERROR: We couldn't find a git remote pointing to 'apache/${repoName}.git' to merge the PR from." |
182 | 184 | echo "INFO: Currently, your configured remotes are:" |
183 | 185 | echo "INFO: ***********************************************************************************" |
184 | 186 | git remote -v |
185 | 187 | echo "INFO: ***********************************************************************************" |
186 | 188 | echo "INFO: To merge a PR, we need access to two remotes: " |
187 | 189 | echo "INFO: 1. Read-only access to GitHub mirror" |
188 | 190 | echo "INFO: 2. Read/write access to Apache git" |
189 | | - echo "INFO: Please add a remote like this: 'git remote add github https://github.com/apache/cloudstack.git'" |
| 191 | + echo "INFO: Please add a remote like this: 'git remote add github https://github.com/apache/${repoName}.git'" |
190 | 192 | echo "INFO: For more help, visit: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61311655" |
191 | 193 | echo "INFO: Once done, run this script again." |
192 | 194 | clean_up_and_exit 1 |
193 | 195 | fi |
194 | 196 |
|
195 | | -echo "INFO: Using remote repository '${github_remote}' to fetch PR (should point to github.com/apache/cloudstack.git)" |
| 197 | +echo "INFO: Using remote repository '${github_remote}' to fetch PR (should point to github.com/apache/${repoName}.git)" |
196 | 198 | echo "INFO: PR #${prId} against branch '${prDestinationBranch}' from '${prAuthor}': '${prTitle}'" |
197 | 199 | echo "INFO: has state '${prState}' and mergable state '${prMergeableState}', about to be merged in branch '${currentBranch}'." |
198 | 200 |
|
@@ -220,6 +222,7 @@ if [ $? -eq 0 ]; then |
220 | 222 | else |
221 | 223 | echo "ERROR: Merge failed, aborting." |
222 | 224 | git merge --abort |
| 225 | + clean_up_and_exit 1 |
223 | 226 | fi |
224 | 227 |
|
225 | 228 | # What's next |
|