Skip to content

Instantly share code, notes, and snippets.

@imesh
Last active August 29, 2015 14:15
Show Gist options
  • Save imesh/4cc0d0e7020a61f0fa3b to your computer and use it in GitHub Desktop.
Save imesh/4cc0d0e7020a61f0fa3b to your computer and use it in GitHub Desktop.
Merge Stratos Pull Requests
#!/bin/bash
# Clone stratos git repository and add github mirror as a remote
# git clone https://git-wip-us.apache.org/repos/asf/stratos.git
# git remote add github https://github.com/apache/stratos.git
set -e
pr_no=$1
pr_branch=pr_${pr_no}
dest_branch="master"
echo "Trying to apply pull request: ${pr_no}"
pushd stratos
echo "Pulling latest changes..."
git checkout ${dest_branch}
git pull --rebase
echo "Fetching the pull request..."
git fetch github pull/${pr_no}/head:${pr_branch}
echo "Checking out ${dest_branch} branch..."
git checkout ${dest_branch}
echo "Rebasing ${pr_branch} on ${dest_branch}..."
git rebase -i ${pr_branch}
git pull --rebase
git commit --allow-empty -m "This closes #${pr_no} on GitHub"
git push origin ${dest_branch}
popd
echo "Successfully merged pull request: ${pr_no}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment