Commit and Pull Request Etiquette #1335
Replies: 2 comments 1 reply
-
@Hallberg-NOAA Would suggestion a template for a PR that the requester would have to fill in. And also, if all the boxes have not been checked, state the reason(s) or expect ...? (statement of consequences! e.g., delay?) |
Beta Was this translation helpful? Give feedback.
-
Following on Bob's second point:
I believe the code would benefit from better documentation of our code changes in the commit logs. In particular, I think we should try to avoid single-line commit messages ( The git commit message is designed to be a proxy for an email, since Linux (for which git was created) is both patched and documented through email patches, and archived in its mailing lists. When we use I would encourage people to start using long-form commit logs with subjects and bodies to help produce some self-documentation of the changes. Just omitting As for how to do this, I admit it can be difficult and don't always know myself how to best achieve it. But I can at least describe my own process.
This would also be the point where we define the "atomicity" of our commits and can ask whether the code builds or passes testing. But we should that as a separate discussion.
Obviously it's very hard to get the perfect sizes right, which is part of the reason for this discussion, but I believe this is a good model of development which will help us to produce more workable commit log. As a second use case, suppose you create a clean, beautiful PR with a perfect set of commits, but now your perfect code is failing some tests. Let's say something very minor like trailing whitespace or an undocumented variable. Recently I have started taking the following approach:
HOWEVER!! If I were to do this on a shared branch like These are just suggestions, and I don't mean to suggest we should immediately start enforcing rules like this. But I do think they are good habits to develop and discuss further. |
Beta Was this translation helpful? Give feedback.
-
Commits are the units in which git records changes, while pull requests are our essential tool for code review, management, and quality control. Within this discussion we would like to address several considerations about the size, granularity, and levels of documentation for commits, pull requests to branches (e.g., dev/ncar) on one of the institutional forks (e.g., NCAR/MOM6), and consolidating pull requests to the common main branch.
To start the discussion, I would like to offer the following observations or suggestions:
Commits are the units for many approaches to debugging. Every commit that is present in a PR should therefore compile and run.
All commits should have comments adequate to describe (1) what they contain, (2) why they were introduced, (3) what are the anticipated consequences, and (4) what tests has the commit passed. For example, a statement like "All answers and output are bitwise identical in the MOM6-regressions and TCs." would cover the last two points in many cases (provided that the code has actually been tested this way).
All answer changing PRs should be as small as possible, with any non-answer changing code changes separated out, to clearly highlight the code changes. In many cases, answer changing PRs should be avoided by adding a runtime bugfix flag.
Single-commit PRs can be very handy, in which case the documentation of the commit should meet the requirements for the documentation of the PR.
It takes about an hour to run all of the automated testing required to assess whether a PR is acceptable, and longer if there are changes to answers or output that must be documented. There can be a case for merging small and trivial commits into a single PR to limit the testing burden.
Multi-commit PRs should have an organizing theme or principle that brings them together.
Multi-commit PRs should come with messages that describe the overall purpose of the PR, and a list of the commits in the PR.
Pulls from the institutional forks to the main branch should have documentation describing what they contain, but they can rely on the underlying PRs for the details of the commits.
Beta Was this translation helpful? Give feedback.
All reactions