Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git / gerrit prevent develop branch to be merged into stable / testing branch

Using Gerrit it is easy to accidentally merge unstable code from the develop branch into the stable branch:

$ git checkout develop
$ commit
$ git push origin HEAD:refs/for/stable

In Gerrit it isn't very clear that the proposed change comes from the develop branch and is to be merged into the stable branch. Is there a way to prevent this merge from happening, either in git or in Gerrit?

Update: For now we use a custom command to push to gerrit which finds the last branch in origin it was based on and only allow pushing to that branch.

like image 430
Taco Avatar asked Nov 13 '22 17:11

Taco


1 Answers

Currently there are no options in software which would prevent You from making this kind of mistake.

There are, however, a few things You could do:

  • train people, so they always check the branch name while performing a review
  • set up a "pushed to correct branch" category (howto here) with options like +1 "Correct branch", 0 "No score", -1 "Incorrect branch", so the reviewer has to formally confirm that he checked the branch name
  • set up a continuous integration tool to automatically review and score the aforementioned category (Jenkins has a plugin You could use)

Would You share the custom command You use to push to gerrit, please?

like image 53
Paweł Polewicz Avatar answered Dec 09 '22 13:12

Paweł Polewicz