Gerrit: working with multiple branches and propagating changes

I am trying to determine the correct way to work with multiple branches on Gerrit, which would correspond to our workflow.

Now we work with branches: we have a wizard and a function branch. A master is an industry that we want to polish and prepare for release, while a function is obviously a field of intensive work. Now, in our particular case, when someone is working on fixing a bug, they:

  • create a change intended for the main branch
  • cherry picks it to target Feature branch change
  • After checking the gerrit code, submit both changes.

Now, as I understand the cherry pick, it selects an individual commit and combines it with the current change. if so, I would expect that eventually there will be no merge conflicts, and indeed this workflow only works fine with GIT. However, Gerrit, most likely due to its nature (branches are not merged remotely as they are locally, and get another sha tag) lists a huge number of conflicting files at the end.

Now I have solved all these problems using the merge strategy (ours by function, they are on the host), but this does not seem right: if something was not common, it was simply discarded.

My question is: is there a safe workflow similar to the one described above that will ultimately lead to a pure merger with gerrit?

+6
source share
2 answers

I would say that in this case it is better to merge than with the cherry pick.

Cherry picks add the same changes, but not the same. Thus, although the source is the same when choosing cherries and merges, the git tree is different. When the tree is different and you merge later, git will assume that the command you previously selected with cherry is missing, and try to merge this change even if the actual code already exists. This is probably why you have a lot of conflicts.

I would suggest a different way of working.

  • When you do the normal work, you design the function and click on Gerrit as usual.
  • When you do a fix (e.g. bug fix) in a stable production environment, you do it directly on master (or local branches, if you want, but not on )
  • When a Gerrit-approved patch is merged into a real wizard , and you can make a transfer request to receive this change in your local copy. Your master version is now the same as Gerrits master
  • Now you will merge all new changes in master into a function . Make sure you rebase so that the patch ends with what you already did in the function
  • After deploying all the new functions, you can combine the function in master , click on Gerrit (if you have permissions, you can pass gerrit by clicking directly on master instead of refs / for / master, as these changes have already been considered)
  • After all changes have occurred in Gerrits master , you click on the master and merge into a function with the rebase function clean branch for work. Of course, this is absolutely true if you have a new feature . Both work fine.
+7
source

I got a little confused as this thread should work fine. If other users submit changes before the error correction is verified / confirmed / submitted, this may lead to merge conflicts, but this should be rare.

If you:

  • Correct the error on the main
  • Click to view (creating change A in gerrit)
  • Change cherry selection A on top of a function branch (resolving any conflicts from master to function)
  • Click the selected cherry blossom to view it (create change B)
  • View / Verify / Submit Changes A and B

Everything will work well. The only way for merge conflicts is if other users download and submit changes between steps 1 and 5. Do you see any other behavior? Can you provide more details?

0
source

Source: https://habr.com/ru/post/921557/


All Articles