Expand description
Issue hygiene of this repository: the form of a pull request, and of
a commit on main. The module book checks the book, wrap
checks the wrap of its pages, blank finds two blank lines in a
row, versions finds the name of a version of riff, ci picks
the checks that just ci runs, and terminal finds the crates of
the terminal in the dependencies of a crate.
§Design
A change reaches main through a pull request, as one squash commit.
GitHub makes the commit from the pull request: its title, then the
number of the pull request, then its body. So the form of the body is
the form of each commit on main:
Closes #77
Pause and resume the riff. A new riff starts paused.
Issue: #77
Milestone: Wave 3- The link line,
Closes #NorRefs #N, links the pull request and the issue. The last pull request of an issue hasCloses #N, so its merge closes the issue. Each other one hasRefs #N. - The trailers
Issue:andMilestone:end the body. They name the issue and the wave in the same form in each commit. The trailerMilestone:names a wave by its number:Wave 3, with no name (milestone_value). The check compares only the number, so a rename of a wave breaks no pull request (names_milestone, 01M518A04JWYJE5FA1VR309SAA). - The trailers stand in the last block of git trailers of the
message (
trailers). Other trailers may stand in the block, before or after them:Signed-off-by:,Generated-by:. At the squash, GitHub adds aCo-authored-by:line for each co-author of the commits, in a paragraph of its own. Sohygiene prchecks the message that the squash will make (PullRequest::squash_message), not only the body. - The merge wraps each line of the body over 72 characters
(
merge_wrap). The tail of a trailer line goes to a line with noKey:, and that line ends the block of trailers. Sohygiene prfails a trailer line over the width (trailer-wrap) before the merge.
hygiene pr N reads pull request N and its issue with gh, and runs
check_pr. hygiene commit [REV] reads the message of a commit
with git, and runs check_commit. Each error names its rule:
| Rule | Finds |
|---|---|
link | A body with no link line, or with more than one. |
keyword | Another closing keyword of GitHub before an issue number, for example Fixes #12. It closes an issue with no check. |
title | A title of a pull request that ends with (#N). GitHub adds the number of the pull request. |
issue-trailer | No Issue: #N trailer, more than one, or one that names another issue than the link line. |
milestone-trailer | No Milestone: trailer, more than one, or one that names another wave than the pull request. |
trailer-wrap | A line of the last block of trailers over 72 characters. The merge wraps it, and the wrapped part is no trailer line (merge_wrap). |
milestone | A pull request or an issue with no milestone, or two different milestones. |
issue-open | An issue that is closed. |
commit-title | A commit title that does not end with (#PR), or that names the issue in place of the pull request. |
use hygiene::{Issue, PullRequest};
let pr = PullRequest::new(
"Pause and resume the riff",
"Closes #77\n\nPause the riff.\n\nIssue: #77\nMilestone: Wave 3\n",
Some("Wave 3"),
);
let issue = Issue::new(77, "OPEN", Some("Wave 3"));
assert!(hygiene::check_pr(&pr, Some(&issue)).is_empty());
let commit = "Pause and resume the riff (#90)\n\nCloses #77\n\nIssue: #77\nMilestone: Wave 3\n";
assert!(hygiene::check_commit(commit).is_empty());Modules§
- blank
- The blank check:
hygiene blank PATH...fails when a Markdown file has two blank lines in a row. - book
- The book check:
hygiene book [DIR]builds the book and fails when it has a missing include or anchor, or when the build changes a tracked file. - ci
- The checks that
just ciruns for a diff. - part
- The parts of the tests of the Gate.
- terminal
- Finds the crates of the terminal in the dependencies of a crate
(01M54216PBE319RASGNMY9F0MR).
riff-clientholds no terminal code: the testriff_client_has_no_terminal_craterunsfoundon itsCargo.tomland on theCargo.lockof the workspace. - versions
- The versions check:
hygiene versions [ROOT]fails when a text names a version of riff. - wrap
- The wrap check:
hygiene wrap [DIR]fails when a prose line of a Markdown file in DIR is longer than 72 characters.
Structs§
- Error
- A broken rule of issue hygiene.
- Issue
- An issue, as
gh issue view --json number,state,milestonegives it. - Milestone
- A milestone, as
gh --json milestonegives it. - Person
- A person, as
ghgives an author.ghleaves out the fields that it does not know. - Pull
Commit - A commit of a pull request: the people that GitHub counts as its
authors. They are the author, and each person of a
Co-authored-by:line. - Pull
Request - A pull request, as
gh pr view --json title,body,milestone,author,commitsgives it.
Enums§
Constants§
- MERGE_
WIDTH - The width of a line in the message of a squash commit: the merge
wraps a longer line (
merge_wrap).
Functions§
- check_
commit - Checks the message of a commit on
main. Returns each broken rule. - check_
pr - Checks a pull request and its issue.
issueisNonewhen the pull request names no issue. Returns each broken rule, in the order of the table of rules. - check_
pr_ for - Checks a pull request and its issue with the rules
rules(check_prwithRules::All). - issue_
number - The issue of a pull request: the issue of its first link line, or of
its
Issue:trailer.hygiene prreads this issue. - issue_
ref - The number of
#N. - merge_
wrap - The text as the squash merge of GitHub leaves it: a line of
MERGE_WIDTHcharacters or fewer stays as it is. A longer line loses its indent and its double spaces, and is filled again with whole words up toMERGE_WIDTHcharacters. The wrapped lines have no indent, and the next line does not join them. A word longer than the width stays on a line of its own. - milestone_
value - The value of the trailer
Milestone:for the milestonetitle: the wave by its number,Wave Nwith no name, or the whole title of a milestone that is not a wave (01M518A07QF1YACBYT91M0DD1R). - names_
milestone - True when the trailer
Milestone: valuenames the milestonetitle. Two waves match by their number, so the name of a wave can change. Each other milestone matches by its whole title (01M518A04JWYJE5FA1VR309SAA). - stray_
keywords - Each closing keyword of GitHub before an issue number, outside the link lines. GitHub closes such an issue at the merge.
- trailers
- The trailers of a message: the lines
Key: valueof its last block of trailers. The block is the last paragraphs of the message that hold only such lines. GitHub adds itsCo-authored-by:lines after a blank line, so the block may have more than one paragraph. A paragraph with a line of another form ends the block, and a last paragraph of that form leaves no trailer at all. - wave_
number - The number N of the wave title
title:Wave N, orWave N: NAMEwith a name that is not blank.Nonefor each other title.