1

Assume that someone is working on legacy code where the complete code is incorrectly indented and every line validates the code-style guidelines.

The user then continues to make changes on a file (lets say with 3000 lines), and applies as a first commit the code-styles from the team automatically, which will have an effect on almost every line. Then he may follow it up with 8 commits to fix only a couple of lines.

When one is reviewing such a merge request, is it possible to review the code without seeing the code-styles changes? The GitLab compare view may even fail to display, because so many lines have been changed. But as a reviewer, I trust the automatic style changes and just want to see the 8 commits which effected only a couple of lines.

I know this situation could be avoided, by making a merge request with the single commit that fixes the code-styles, and then creating another merge request for the other changes. But what if you end up in a situation where someone did it in a single MR. Any chance I can review it without becoming insane?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Adam
  • 25,960
  • 22
  • 158
  • 247

1 Answers1

1

It's trivial to turn it into two merge requests, and that is the best option. Simplest is to thank them for their work, explain it is very difficult to review as a single request, and if they would split it up themselves.

Or you can do it yourself. Make a branch off their first commit, git branch <new branch> <first commit ID>, and submit that as a merge request. Merge it. Then rebase the original merge request on master. They'll still get credit for the work.

You could also compare their branch with their second commit. Go to the "compare" tool, set their branch as the source and the commit ID of their second commit as the target.

And you could review it commit by commit in the Commits tab.

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • That is great, did not know about `restyle`. When you say that I could review it commit by commit, do you mean that I go in the commit history, copy paste the two commit id by hand and then use something by https://gitlab.com/$USER/$REPO/compare?from=$SHA1&to=$SHA2 - or is there a quick way to review commit by commit? – Adam Oct 23 '20 at 07:41
  • 1
    @Adam `restyle` is just the name I chose for the branch, it has no special meaning. To review commit by commit, use the "Commits" tab to list all the commits. – Schwern Oct 23 '20 at 07:43
  • Whoups misread, so no magic, makes sense. Can't belive I missed the commit-by-commit review possiblity. In that case, there is no need to split the merge request, right? – Adam Oct 23 '20 at 07:48
  • @Adam I suppose if the merge request is very small, otherwise it's hard to see the totality of the work. I'd suggest instead using the Compare tool and compare their branch with their 2nd commit, see the updated answer. Splitting the merge request is faster and better and something good to be comfortable with. – Schwern Oct 23 '20 at 07:51
  • Today I had a review of someone, who did the styling changes and coding in one single commit. I was eager to use my new knowledge and then this..lol – Adam Oct 23 '20 at 18:07