01 – GitLab branch protecting and working with pull requests

 

More and more IT companies insist on quality assurance process and tools to achieve it. Certainly, one of them is mutual reviewing code by developers. Good quality application is much easier and cheaper to maintain. 

But… The code review process arouses controversy among developers. Not everyone agrees to check the quality of its code. In my opinion it’s better to include code review process into natural git flow other than manual check every commit after merge to master branch. Another advantage is, that master branch is much more stable. Sometimes we have to stop ours Harleys in the name of better software.

In this tutorial I will show you how to enforce pull requests in GitLab, but first of all you need to know that developers are allowed to push changes to non protected branches. Masters are responsible for merging them with main branches and to maintain project consistency.

Requirements

Preparation

Push to master – branch protection test

Clone G04-gitlab-pull-requests repository as tutorial_developer user.

As you can see the push was blocked.

Creating pull request

First of all you need to switch/create another branch: my-test-branch and push it to origin.

Now create pull request  as tutorial_developer user (my-test-branch -> master) and accept it as tutorial_master user.

 

Addititionals

  • More about user permissions you can find here.
  • Very good guide about git branch layout and git workflow you can find here.

Exercises

  • Create your your own protected branch layout based on one of described here.
  • Try to create custom user permission layout to achieve above branch layout.
  • Test it in practice.
Facebooktwittergoogle_plusredditlinkedinmail

Leave a Reply

Feel free to ask me about anything!

Notify of
avatar
wpDiscuz