GitFlow and code reviews

Posted on May 04, 2015 · 2 mins read · tagged with: #code review #git #git flow

Presentation1Many companies that uses GIT as its code repository use git-flow as the branching model for its projects. The question, that one can come up with is where and when the code review should be taken? Should it be before:

git flow feature finish MYFEATURE

If yes, then the reviewer looks through some version of code, but still, the person responsible for closing the feature creates a a new merge commit after all which can change a lot. On the other hand, if the reviewer creates the merge commit, he/she may not know all the aspects needed for a successful merge. There are a few pages trying to answer this, but still I haven’t found anything satisfying. Please read further for my proposal of clean and proper code review process with git-flow.

The problem with git-flow is the fact that finishing a feature is an atomic action. In one action the author does plenty of things

  1. Author: pushes the commit to the remote
  2. Reviewer: reviews the code
  3. A: creates a merge commit (new commit created!)
  4. A: moves the develop cursor to the new commit

  5. A: deletes the feature branch
  6. A: pushes to the remote

As always, splitting one action into multiple and then proper grouping might help. Consider the following flow including the author and the reviewer.

  1. Author: creates a merge commit
  2. A: moves the feature/a to the merge commit

  3. A: pushes the merge commit to the remote
  4. Reviewer: reviews the merge commit
  5. R: if the review is successful, rebase the develop with fast-forward to the merge commit (some automation can be introduced).

According to this flow, the reviewer always reviews the commit which will land in the develop. Additionally, this makes the author of the feature branch aware of merge problems before he/she pushes out his/her work to the review. Effectively, a feature can be completed and merged and simply wait for acceptance which then, is a simple “go/no go” without considering merge conflicts later on.

This isn’t a git-flow anymore, but still, it is a solid flow to lower the context switching of the author. Ones he/she finishes, it’s a real end, not an entry for incoming merge.


Comments

[…] the recent post I’ve described the idea how to ensure, that your feature-to-develop GitFlow merge commits are […]

by GitFlow and Continuous Build | Extreme .NET programming at 2015-05-07 08:03:21 +0000

What if other feature must be merged, is reviewed successfully, but the first one should be fixed and is blocker for the second one?

by Sławomir Bryś (@slawomirbrys) at 2015-11-05 15:39:04 +0000

You merge from develop. Having all develop commits tested/reviewed/deployed greatly lowers probability of this. If you need a fixup, do it in a separate brach, merge from develop review/test/deploy and ff develop back. The flow is the same, isn't it?

by scooletz at 2015-11-05 21:10:08 +0000

[…] time ago I wrote a few entries about my attitude to the GitFlow and a small adjustment that can greatly reduce the possibility of breaking development/release branches. The main […]

by Protect development at all cost | Extreme .NET programming at 2015-12-04 09:05:25 +0000