馃枌Commit by commit code review
## Problem to solve Commit by commit review process ensure good commit hygiene, by treating each commit as a reviewable change. There are significant benefits to the practice of thinking carefully about each commit that benefit the author, reviewers and future engineers. Commit by commit review is practiced by large open source projects like Git and Linux where changes are submitted to mailing lists as a set patches. Each patch is reviewed individually and in the context of the set of patches. Commit by commit reviews are also supported by other tools too. **Side note:** it is confusing that merge requests reviewed as a single unit might be merged as multiple commits. If the total code change can be reviewed as a single change, shouldn't it probably be merged as a single commit? ## Vision GitLab should support commit by commit review workflows as well as our the current review workflow which visualizes the diff as a single patch. ## Further details Since small changes are faster to review, and are result in more useful comments ([Characteristics of Useful Code Reviews: An Empirical Study at Microsoft, 2015](https://www.microsoft.com/en-us/research/publication/characteristics-of-useful-code-reviews-an-empirical-study-at-microsoft/)), we should encourage workflows that result in smaller commits. ## Proposal Improving support will require a range of changes to the merge request interface. - **Improved navigation and comparison of commits in merge requests** https://gitlab.com/groups/gitlab-org/-/epics/2399 Commits are currently hard to view and move between, making a commit focused flow all but impossible. Furthermore the commit message isn't displayed clearly or in full by default. - **Commit messages as part of code review** https://gitlab.com/groups/gitlab-org/-/epics/286 Commit messages are very important in commit based workflows and describe the content being reviewed. - **Policy and controls** https://gitlab.com/groups/gitlab-org/-/epics/2893 When practicing commit focused workflows, it is important that the application provides policies and controls that help achieve good commit hygiene. Specifically, requiring all commits to pass tests, and have allowing commit level approvals. ## Longer term There is much fertile ground for improving review workflows above the minimums of the topics described above, including: - **Rewording commit messages in GitLab** https://gitlab.com/groups/gitlab-org/-/epics/2894 - **Merge individual commits from a merge request** This has consequences for approval because approval requirements need to be met for each merge unit. ## Customers - https://gitlab.my.salesforce.com/00161000004bZKw ~customer - https://gitlab.my.salesforce.com/00161000004bZPD ~customer - https://gitlab.my.salesforce.com/0016100001F2Gsw ~customer ## Links / references - https://gregoryszorc.com/blog/2020/01/07/problems-with-pull-requests-and-how-to-fix-them/ - https://research.google/pubs/pub47025/ - https://www.microsoft.com/en-us/research/publication/characteristics-of-useful-code-reviews-an-empirical-study-at-microsoft/ - https://www.microsoft.com/en-us/research/publication/code-reviews-do-not-find-bugs-how-the-current-code-review-best-practice-slows-us-down/
epic