Deutsch
The Gitlab fox on Sebastian Helzle's Blog

Code reviews made simple

Categories:

The problem

Working on more complex projects makes it at one point necessary to do code reviews. You should even do it for small and easy projects but from my perspective the real need arises when you start to have problems with code quality, regressions or you just want to spread knowledge in a team.

In our projects we don't have a code review tool like Gerrit and we are not yet sure if it really helps us or slows us down when working in a small team.

A while ago I started using Gitlab in several projects to have something like Github but without giving them my data. I won't go into explaining how to install or setup Gitlab. There are great guides and the setup and upgrades are really easy.

See what's going on

List of latest commits

Seeing the latest commits in a branch of a project is very useful. You can see who did what and when.

Having this view already helps in keeping up to date on what's going on in your projects code repository.

I've been using this view to check mostly twice a day what new commits came in and when I saw something which I thought could be improved or liked a lot I left a comment or directly talked with the commits author.

Say what you think

Commit details

When you click on a commit you can see what has changed in which files.

You can do a side-by-side comparison and also leave a comment. You can do this for a specific line or for the whole commit.

It's always good to give comments even on small things. Sometimes you think you can just fix a typo here or a wrong indentation here but most of the time I think it's better to leave a comment and tell the commiter just to fix it. This way everybody tries to improve the code and you don't feel like a cleaner.

Leaving comments for a very good piece of code is also nice. On the other hand I don't like rude comments but they should be short and exact. 

Loosing overview

Interface of the app tower

In my opinion keeping overview over one project like this is easy when there are less then 10-20 medium size commits a day. I can get difficult if the commit messages are bad or there are commits which are directly related to one another but this is another problem related to using Git and how your team works.

My problems started when I wanted to review the commits of multiple projects and even multiple branches in one project. Because it took more time clicking through all of those lists and remembering what I already looked at.

When I'm not directly working with my terminal I'm using Tower as Git client. This already helps to have a better view over changes, tags, submodules and everything else. Maybe it's not as fast to work with as in the terminal but the better overview makes me more efficient when working in a team.

I remembered something

Interface of the app reeder

Some weeks ago I read an article about how good the Reeder app for Mac has gotten. I've been using this app already on my iPad and iPhone and I love it.

Yesterday I finally installed it again on my Mac and I saw how perfect the controls are. You can swipe panels left and right, enable readability and open an article in the integrated browser.

After connecting my fever account, playing a while with the app and deciding that I will continue using it I remembered something:

Gitlab has feeds!

RSS button in Gitlab interface

On the top right of the commit list there is a small feed icon. Clicking it while give you an atom feed containing the a list with the basic information about the commits.

Each entry contains the title, description, date, author, project name and branch name.

You can copy the url of the feed and add it to your favorite feed reader. As you can guess I did that with Reeder.

Setting up the feeds

Add account in reeder interface

You can add a local RSS account in Reeder by going into preferences.

There you add it by selecting "RSS (local, no syncing)". It has some options like the title, how often it should update, how to sort items and other stuff. Just check it out and see what fits for you.

I set it up for updating my feeds every 30 minutes and only mark items as read when I mark the manually. You can also set it to automatic but this way sometimes you can overlook a commit by accident.

Adding a subscription

Add new subscription dialog in reeder

After adding the new account you can close the preferences and select the account in the leftmost panel.

It has a panel right next to it which will contain your future subscriptions.

Add a new subscription by clicking on the small "plus" sign at the bottom.

Paste the url you copied from Gitlab into the dialgo and click "Search".

Subscription details in reeder app

Reeder will check the url and show you some more details about the feed.

Select in which folder you want to put it and click "Subscribe" to add it to your subscriptions.

It worked!

Gitlab feed in Reeder

You should now have a subscription called "Recent commits to [some projectname]". 

The third panel in Reeder will show you the list of recent commits you already saw in Gitlab.

Clicking an item will show you more details about the commit, you can mark it as read or even give it a star so you can review it later. Commits you already looked at should be marked as read and won't show up unless you also make read items visible.

Have a look at the preferences of Reeder to see how you can control the app with gestures and hotkeys. It's really useful and makes you much faster.

Add as many subscriptions for as many projects and branches as you need.

Where's the code?

Commit details in Reeder

OK now I can really fast go trough all the commits I'm interested in but I also want to see the code.

Reeder has an integrated browser. Just swipe to the left or click on the commits title and it will move all panels to the left and open Gitlab in a preview panel.

This first time you do this Gitlab will ask for your login like it would in every other browser. After that it will open the same commit view you already know from the beginning of my article. It also behaves exactly the same way. You can leave comments, click around and use every other feature Gitlab has to offer.

Things got much better!

This way my code reviews became faster and simpler. I have all features of Gitlab but I won't miss any commit. If Gitlab gets a new feature, my review system also gets it. Same thing for Reeder.

Reeder will also show you the number of new commits in the apps icon if you want. But it can be disabled if you don't want to be distracted.

You can of course use any feed reader app you want.

Any feedback to this is welcome :)