Skip to content

Commit daca285

Browse files
committed
chore: further tweaks for the title checks around capitalisation (leanprover-community#40179)
Also allow a few selected suffixes to abbreviations. And make the error messages about suffixes more detailed.
1 parent 94f630c commit daca285

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

Mathlib/Tactic/Linter/ValidatePRTitle.lean

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,17 @@ public def validateTitle (title : String) : Array String := Id.run do
119119
-- Future: we could check if `scope` describes a directory that actually exist.
120120
-- Should we allow special syntax such as `Data/*/Basic` or `{Set,Group}Theory`?
121121

122-
-- Titles should be lower-cased (but we allow abbreviations).
122+
-- Titles should be lower-cased (but we allow abbreviations, or a `s` or `'ed` suffix).
123123
if subject.front.toLower != subject.front then
124124
let firstWord := subject.takeWhile (!·.isWhitespace)
125-
if !isAbbreviation firstWord then
126-
errors := errors.push "error: the PR subject should be lowercased"
125+
let suffixes := ["'s", "s", "'ed"]
126+
let mut withoutSuffix := firstWord
127+
for suff in suffixes do
128+
if firstWord.endsWith suff then
129+
withoutSuffix := firstWord.dropSuffix suff
130+
break
131+
if !(isAbbreviation withoutSuffix) then
132+
errors := errors.push s!"error: the PR subject `{subject}` should be lowercased"
127133
if subject.endsWith "." then
128134
errors := errors.push "error: the PR title should not end with a full stop"
129135
else if subject.endsWith " " then

MathlibTest/ValidatePRTitle.lean

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,35 @@ section subject
114114
#guard_msgs in
115115
#check_title "feat: bad title."
116116

117-
/-- info: Message: 'error: the PR subject should be lowercased' -/
117+
/-- info: Message: 'error: the PR subject `My Bad Title` should be lowercased' -/
118118
#guard_msgs in
119119
#check_title "feat: My Bad Title"
120120
-- Starting with an acronym is fine, however.
121121
#guard_msgs in
122122
#check_title "feat: RPC acronyms are fine"
123+
#guard_msgs in #check_title "feat: `ℕ` is countable"
124+
-- We also allow a `s`, `'s` or `'ed` suffix, as manual heuristic.
125+
#guard_msgs in #check_title "feat: RPCs are yellow"
126+
#guard_msgs in #check_title "chore: LLMs require adjusting our policies"
127+
#guard_msgs in #check_title "chore: PR'ed lemmas"
128+
#guard_msgs in #check_title "feat(CI): PR's to be deleted"
129+
#guard_msgs in #check_title "chore: FCP'ed decisions should be listed separately"
130+
-- We only remove at most one suffix.
131+
/-- info: Message: 'error: the PR subject `PR'ed's lemmas` should be lowercased' -/
132+
#guard_msgs in #check_title "chore: PR'ed's lemmas"
133+
/-- info: Message: 'error: the PR subject `PRs's something` should be lowercased' -/
134+
#guard_msgs in #check_title "chore: PRs's something"
135+
-- This is not quite an abbreviation (and a grammar error).
136+
/--
137+
info: Message: 'error: the PR subject `FCPed decisions should be listed separately` should be lowercased'
138+
-/
139+
#guard_msgs in #check_title "chore: FCPed decisions should be listed separately"
123140

124141
-- This PR title is arguably not very bad (Lindelöf is a proper name),
125142
-- a better fix is to start with a verb (which you should do anyway.)
126-
/-- info: Message: 'error: the PR subject should be lowercased' -/
143+
/--
144+
info: Message: 'error: the PR subject `Lindelöf spaces something something` should be lowercased'
145+
-/
127146
#guard_msgs in
128147
#check_title "feat: Lindelöf spaces something something"
129148

@@ -196,13 +215,13 @@ info: Message: 'error: the PR title contains multiple consecutive spaces; please
196215
#guard_msgs in
197216
#check_title "feat(ModuleForm): 2e is less than 6"
198217

199-
/-- info: Message: 'error: the PR subject should be lowercased' -/
218+
/-- info: Message: 'error: the PR subject `W3c` should be lowercased' -/
200219
#guard_msgs in
201220
#check_title "feat(ModuleForm): W3c"
202221

203222
#guard_msgs in
204223
#check_title "feat(ModuleForm): W3C"
205224

206-
/-- info: Message: 'error: the PR subject should be lowercased' -/
225+
/-- info: Message: 'error: the PR subject `A new lemma` should be lowercased' -/
207226
#guard_msgs in
208227
#check_title "feat(ModuleForm): A new lemma"

0 commit comments

Comments
 (0)