Developing and Submitting a Patch¶
We use a web-based code review system called Gerrit. Using this system, anyone can comment on a proposed change before it is merged to our Git repository. It’s pretty easy to use; the instructions below will get you started.
Create a Gerrit Account¶
- Navigate to http://review.motechproject.org/
- Click sign in on top-right
- Select Open ID provider (only Google accounts are enabled)
- Select user name
- Upload your SSH public key
Configuring Your Git Client to Use Gerrit¶
Follow these steps once for each MOTECH code repository that you clone.
Get source code
git clone ssh://<userid>@review.motechproject.org:29418/motech
Set up review branch
cd motech git config remote.origin.push refs/heads/*:refs/for/*
Install change-id generation hook
scp -p -P 29418 <userid>@review.motechproject.org:hooks/commit-msg .git/hooks/
Checkout to feature branch
git checkout -b newfeature
Make changes/test/multiple commits
When ready to submit changes: update master, squash commits and merge feature branch
git checkout master && git pull --rebase git merge --squash newfeature git gui
Edit commit message using the proper commit message format
git push origin
Submitting Changes (Patch Set) to Incorporate Review Comments¶
If you’ve received some code review feedback and you’d like to make some changes, follow the steps below to add your changes as a new “patch set” to the existing Gerrit code review.
Pushing to Remote Branches (Not for Review)¶
This practice enables developers to share in-progress feature work with others without actually submitting the changes for review.
Use branch namespace dev
git checkout -b dev/newfeature git add . && git commit -m "message" git push -u origin dev/newfeature:dev/newfeature
Once done with feature, squash commits and merge with master. Submit for review as mentioned above.