mirror of https://github.com/apache/cloudstack.git
make it work with any Apache repository mirrored on GitHub
This commit is contained in:
parent
23b9365996
commit
fed5c2b06a
|
|
@ -47,6 +47,7 @@ fi
|
|||
# Check the arguments
|
||||
if [ -z ${prId} ]; then
|
||||
echo "Usage: git pr pool-request-number [ --force ]"
|
||||
echo "Works for any Apache repository mirrored on GitHub'"
|
||||
echo "For instructions, see: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61311655"
|
||||
clean_up_and_exit 1
|
||||
fi
|
||||
|
|
@ -54,13 +55,14 @@ fi
|
|||
# Vars we need
|
||||
jsonTmp="${PWD}/${prId}.json"
|
||||
tmpMessageFile="${PWD}/.git-tmp-message.txt"
|
||||
repoName=$(basename `git rev-parse --show-toplevel`)
|
||||
|
||||
# We need UTF-8 to support the GitHub '...' 3-dots-in-1-char, for example.
|
||||
export LANG="en_EN.UTF-8"
|
||||
|
||||
if [ "${prId}" -eq "${prId}" 2>/dev/null ]; then
|
||||
# Get json data from Github API
|
||||
curl -s https://api.github.com/repos/apache/cloudstack/pulls/${prId} > ${jsonTmp}
|
||||
curl -s https://api.github.com/repos/apache/${repoName}/pulls/${prId} > ${jsonTmp}
|
||||
else
|
||||
echo "ERROR: Pull-request id must be an integer, not '${prId}'"
|
||||
clean_up_and_exit 1
|
||||
|
|
@ -176,9 +178,9 @@ elif [ "${prMergeableState}" != "clean" ] && [ ${force} -eq 1 ]; then
|
|||
echo "WARNING: You used --force to merge a PR with non-clean merge state '${prMergeableState}'."
|
||||
fi
|
||||
|
||||
github_remote=$(git remote -v | grep "apache/cloudstack.git" | head -n 1 | cut -f1)
|
||||
github_remote=$(git remote -v | grep -E "apache/${repoName}(.git)?" | head -n 1 | cut -f1)
|
||||
if [ ${#github_remote} -eq 0 ]; then
|
||||
echo "ERROR: We couldn't find a git remote pointing to 'apache/cloudstack.git' to merge the PR from."
|
||||
echo "ERROR: We couldn't find a git remote pointing to 'apache/${repoName}.git' to merge the PR from."
|
||||
echo "INFO: Currently, your configured remotes are:"
|
||||
echo "INFO: ***********************************************************************************"
|
||||
git remote -v
|
||||
|
|
@ -186,13 +188,13 @@ if [ ${#github_remote} -eq 0 ]; then
|
|||
echo "INFO: To merge a PR, we need access to two remotes: "
|
||||
echo "INFO: 1. Read-only access to GitHub mirror"
|
||||
echo "INFO: 2. Read/write access to Apache git"
|
||||
echo "INFO: Please add a remote like this: 'git remote add github https://github.com/apache/cloudstack.git'"
|
||||
echo "INFO: Please add a remote like this: 'git remote add github https://github.com/apache/${repoName}.git'"
|
||||
echo "INFO: For more help, visit: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61311655"
|
||||
echo "INFO: Once done, run this script again."
|
||||
clean_up_and_exit 1
|
||||
fi
|
||||
|
||||
echo "INFO: Using remote repository '${github_remote}' to fetch PR (should point to github.com/apache/cloudstack.git)"
|
||||
echo "INFO: Using remote repository '${github_remote}' to fetch PR (should point to github.com/apache/${repoName}.git)"
|
||||
echo "INFO: PR #${prId} against branch '${prDestinationBranch}' from '${prAuthor}': '${prTitle}'"
|
||||
echo "INFO: has state '${prState}' and mergable state '${prMergeableState}', about to be merged in branch '${currentBranch}'."
|
||||
|
||||
|
|
@ -220,6 +222,7 @@ if [ $? -eq 0 ]; then
|
|||
else
|
||||
echo "ERROR: Merge failed, aborting."
|
||||
git merge --abort
|
||||
clean_up_and_exit 1
|
||||
fi
|
||||
|
||||
# What's next
|
||||
|
|
|
|||
Loading…
Reference in New Issue