LoveWithFood Tech

LWF

Git_pretty_accept: Accept Pull Requests the Pretty Way!

| Comments

A few months ago, I suggested the Simple Git Branching Model and Best Way To Merge A (GitHub) Pull Request to Hendy, our CTO. We were using GitHub’s pull request feature for our code reviews, and as great as that feature was, it was turning our git history into, sorry for the pun, spag-git-ti. With the Simple Git Branching model, I was hoping for a more linear, more readable git history, with visible feature branches that can be easily reverted.

Hendy liked the idea, but felt that the workflow needed to be automated. With a script, accepting pull requests will be consistent and error-resistant.

And so, after several weeks of testing and usage, we’re happy to share git_pretty_accept.

git_pretty_accept is a ruby gem that rebases a pull request before merging it to master. The pull requests are always merged recursively to make branches visible in the history.

To accept a pull request, just run git pretty-accept BRANCH_NAME in the branch where BRANCH_NAME will be merged.

You can also provide a merge commit template .git-pretty-accept-template.txt to your project directory. This is great if you want your merge commits to follow a certain format e.g. you want your team to enter the issue link when accepting pull requests.

We wrote git_pretty_accept for our particular workflow. If you’d like to use the gem, here are a few things you’ll need to keep in mind. The script

  1. Assumes that your remote repository is origin. It doesn’t work yet with Github forks.
  2. Automatically removes the local and remote branch of the pull request once the pull request is merged.
  3. Complains if you accidentally try to accept the master branch.

Let us know what you think! Pull requests are most welcome.

Comments