Proposal
I would like to propose that we require pull requests and disable direct pushes for all contributions to repositories in the llvm organization with the exception of the user/* branches that are used for stacked PRs. The main incentive for this proposal is to enable accurate tracking of authorship of each commit, to enable better auditing during supply chain security incidents. There are a few examples below where we needed this recently. In addition to this, requiring pull requests will make it easier to do post-commit review for all commits.
Authors
Benefits
-
This change will make it possible to accurately track authorship of a commit. Currently, the only way to track authorship of commits is by looking at the author field of the git commit. However, this information is supplied by the committer and it is trivial to put another author’s name on your commit. We’ve recently had two[1][2] instances where we needed to search for commits made by a certain github user, and it is impossible to do this without requiring pull requests. Being able to accurately track authorship is important for security auditing.
-
It enables better post-commit reviews. We don’t really have a good space to do post-commit reviews on commits that are directly pushed to the repository. Requiring pull requests will fix this by creating a natural space (pull request) to review each commit. This will enable better visibility to the community of which of the “post-commit review” commits actually had any review or not.
-
Reverts can be made through the UI. This is a much more convenient way to revert a patch than having to manually do it on a local git checkout. It also makes it easier to track which commits have been reverted, which is useful when backporting fixes or trying to track down regressions.
Impact
To get an idea of how this change would impact the project, on April 9, I took a sample of the latest 100 commits and categorized each commit based on type and if there was a PR or not:
| PR | Type | Count |
|---|---|---|
| Yes | N/A | 60 |
| No | Other | 16 |
| No | NFC | 13 |
| Yes | Manual Push | 4 |
| No | Revert | 2 |
| No | Bazel | 2 |
| No | GN | 1 |
| No | Re-Commit | 1 |
| No | Pre-Commit Test | 1 |
From what I can tell, the ‘Other’ category is mainly commits from code owners for changes that qualify for post-commit review. So, the most common use cases that will be affected by this change are this and also NFC changes. In order to minimize the inconvenience of this change on these workflows, we will add a helper script that will submit a PR and automatically merge it, so that these kinds of changes can still be done with a single command on the command line.
Timeline
If this proposal is accepted, then 60 days after its acceptance, pull requests will become required. The first 30 days would be used for developing the script to enable the “create PR and merge” workflow and to work with a few people who make use of this workflow frequently to make sure that it remains easy. On day 31, we will configure GitHub to emit a warning when someone pushes directly, then pull requests will become required on day 60.