...
bk-merge-pr.py
is a script that automates the process of accepting a code change into the project. It creates a temporary branch from apache/master
, squashes the commits in the pull request, rewrites the commit message in the squashed commit to follow a standard format including information about each original commit, merges the squashed commit into the temporary branch, pushes the code to apache/master
and closes the JIRA ticket. The push will then be mirrored to apache-github/master
, which will cause the PR to be closed due to the pattern in the commit message. Note that the script will ask the user before executing remote updates (ie git push and closing JIRA ticket), so it can still be used even if the user wants to skip those steps.
Setting Up
1. Add aliases for the remotes expected by the merge script (if you haven't already):
git remote add apache git remote add apache-github https: //github.com/apache/bookkeeper.git |
The 'apache' repository is the one you are going to 'push" and the 'apache-github' repository is the one from which you are going to 'pull'
2. Install jira-python:
sudo easy_install jira
3, Link your Apache ID, your GitHub id. Follow the instructions here
https://gitbox.apache.org/setup/
You will need to enable "two factors authentication" of GitHub in order to bind your Apache profile to your GitHub profile
Remember that from the command we have to use GitHub Personal Access Tokens in place of passwords (https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ )
Merging
Once the pull request is ready to be merged (it has been reviewed, feedback has been addressed, CI build has been successful and the branch merges cleanly into master):
1. Set the JIRA_USERNAME
and JIRA_PASSWORD
environment variables with the appropriate credentials if you intend to ask the script to close the issue associated with the pull request.
2. Run the merge script:
python dev/bk-merge-pr.py |
3. Answer the questions prompted by the script.
Merge old patches attached to JIRA
Create a branch to work on:
git fetch
git checkout -b xyz remotes/origin/master
- Download the patch
Apply
git apply BOOKKEEPER-XXXX.patch
- Make sure unit tests pass
- Push the change back to Apache. You should almost always collapse your work into a single check-in in order to avoid cluttering the upstream change-log:
# assuming master is up-to-date with origin
git checkout master
git merge --squash xyz
git commit -am
"BOOKKEEPER-XXX: title"
--author=
"firstname lastname <contributoremail>"
git push origin master