mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-11 21:22:47 +01:00
lint: Call lint_commit_msg from test_runner
Allowing to call the check from the test_runner allows for consistent error messages. Also, manually setting the commit range is no longer needed.
This commit is contained in:
@@ -73,6 +73,11 @@ fn get_linter_list() -> Vec<&'static Linter> {
|
||||
name: "scripted_diff",
|
||||
lint_fn: lint_scripted_diff
|
||||
},
|
||||
&Linter {
|
||||
description: "Check that commit messages have a new line before the body or no body at all.",
|
||||
name: "commit_msg",
|
||||
lint_fn: lint_commit_msg
|
||||
},
|
||||
&Linter {
|
||||
description: "Check that tabs are not used as whitespace",
|
||||
name: "tabs_whitespace",
|
||||
@@ -243,6 +248,42 @@ fn lint_scripted_diff() -> LintResult {
|
||||
}
|
||||
}
|
||||
|
||||
fn lint_commit_msg() -> LintResult {
|
||||
let mut good = true;
|
||||
let commit_hashes = check_output(git().args(&[
|
||||
"-c",
|
||||
"log.showSignature=false",
|
||||
"log",
|
||||
&commit_range(),
|
||||
"--format=%H",
|
||||
]))?;
|
||||
for hash in commit_hashes.lines() {
|
||||
let commit_info = check_output(git().args([
|
||||
"-c",
|
||||
"log.showSignature=false",
|
||||
"log",
|
||||
"--format=%B",
|
||||
"-n",
|
||||
"1",
|
||||
hash,
|
||||
]))?;
|
||||
if let Some(line) = commit_info.lines().nth(1) {
|
||||
if !line.is_empty() {
|
||||
println!(
|
||||
"The subject line of commit hash {} is followed by a non-empty line. Subject lines should always be followed by a blank line.",
|
||||
hash
|
||||
);
|
||||
good = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if good {
|
||||
Ok(())
|
||||
} else {
|
||||
Err("".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
fn lint_py_lint() -> LintResult {
|
||||
let bin_name = "ruff";
|
||||
let checks = format!(
|
||||
|
||||
Reference in New Issue
Block a user