Add minimal merge-ref based diff option to merge request comparisons
Problem to solve
Merge request diffs are currently calculated by git diff target...source
which compares HEAD
of target
with the merge base of target
and source
. This works well until changes from the target branch are merged in to the source branch, creating a complete mess of the diff.
Intended users
Developers
Further details
For a Developer using GitLab, code review is primarily reading the diff generated by GitLab and leaving feedback. If the diff contains changes that have already been merged to the target branch this is:
- confusing to the reviewer because they will be seeing unrelated changes in the diff
- time consuming for the reviewer because they will have to review a larger diff, and spend more time working out in their head what changes are actually being merged
- time consuming for the author who must wait on a longer review cycle and reduce cycle time.
Merge refs will allow us to calculate a more accurate diff that doesn't have these issues.
Proposal
When a person is reading a merge request diff, a new diff mode will be available in the drop down master (HEAD) indicating that this diff is against the head of the target branch, not the merge base of the target and source branch.
Behind the scenes this will use the merge-ref feature implemented for CI.
Every time the target branch is updated the merge request diff becomes out of date which happens over 20 times a day for gitlab-ce
.
Limitations
In this first iteration:
- commenting will not be supported on the new master (HEAD) mode
- instead of automatically recalculating the diff when commits are pushed to the source or target branch, automatically recalculate the diff the next time the merge request is loaded
In the future, the new diff mode will replace the existing diff mode once commenting support is implemented and performance improvements have been made.
Documentation
Testing
What does success look like, and how can we measure that?
GitLab should have accurate diffs that do not show misleading information. Although this is a feature, it is perceived as a bug by our customers who have noted that the diffs in GitHub and Bitbucket better meet their expectations. Thus, success is measured by no long receiving bug reports and support requests about diff accuracy.