File tree Expand file tree Collapse file tree 2 files changed +41
-52
lines changed Expand file tree Collapse file tree 2 files changed +41
-52
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ fn get_linter_list() -> Vec<&'static Linter> {
73
73
name: "scripted_diff" ,
74
74
lint_fn: lint_scripted_diff
75
75
} ,
76
+ & Linter {
77
+ description: "Check that commit messages have a new line before the body or no body at all." ,
78
+ name: "commit_msg" ,
79
+ lint_fn: lint_commit_msg
80
+ } ,
76
81
& Linter {
77
82
description: "Check that tabs are not used as whitespace" ,
78
83
name: "tabs_whitespace" ,
@@ -243,6 +248,42 @@ fn lint_scripted_diff() -> LintResult {
243
248
}
244
249
}
245
250
251
+ fn lint_commit_msg ( ) -> LintResult {
252
+ let mut good = true ;
253
+ let commit_hashes = check_output ( git ( ) . args ( & [
254
+ "-c" ,
255
+ "log.showSignature=false" ,
256
+ "log" ,
257
+ & commit_range ( ) ,
258
+ "--format=%H" ,
259
+ ] ) ) ?;
260
+ for hash in commit_hashes. lines ( ) {
261
+ let commit_info = check_output ( git ( ) . args ( [
262
+ "-c" ,
263
+ "log.showSignature=false" ,
264
+ "log" ,
265
+ "--format=%B" ,
266
+ "-n" ,
267
+ "1" ,
268
+ hash,
269
+ ] ) ) ?;
270
+ if let Some ( line) = commit_info. lines ( ) . nth ( 1 ) {
271
+ if !line. is_empty ( ) {
272
+ println ! (
273
+ "The subject line of commit hash {} is followed by a non-empty line. Subject lines should always be followed by a blank line." ,
274
+ hash
275
+ ) ;
276
+ good = false ;
277
+ }
278
+ }
279
+ }
280
+ if good {
281
+ Ok ( ( ) )
282
+ } else {
283
+ Err ( "" . to_string ( ) )
284
+ }
285
+ }
286
+
246
287
fn lint_py_lint ( ) -> LintResult {
247
288
let bin_name = "ruff" ;
248
289
let checks = format ! (
You can’t perform that action at this time.
0 commit comments