lint: [move-only] Move repo related lints to lint_repo_hygiene.rs
Also, run cargo fmt on main.rs
This commit is contained in:
2 files changed
+43
-36
No files matched your search
@@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or https://opensource.org/license/mit/.
|
||||||
|
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
use crate::util::{commit_range, get_subtrees, LintResult};
|
||||||
|
|
||||||
|
pub fn lint_subtree() -> LintResult {
|
||||||
|
// This only checks that the trees are pure subtrees, it is not doing a full
|
||||||
|
// check with -r to not have to fetch all the remotes.
|
||||||
|
let mut good = true;
|
||||||
|
for subtree in get_subtrees() {
|
||||||
|
good &= Command::new("test/lint/git-subtree-check.sh")
|
||||||
|
.arg(subtree)
|
||||||
|
.status()
|
||||||
|
.expect("command_error")
|
||||||
|
.success();
|
||||||
|
}
|
||||||
|
if good {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err("".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn lint_scripted_diff() -> LintResult {
|
||||||
|
if Command::new("test/lint/commit-script-check.sh")
|
||||||
|
.arg(commit_range())
|
||||||
|
.status()
|
||||||
|
.expect("command error")
|
||||||
|
.success()
|
||||||
|
{
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err("".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
mod lint_cpp;
|
mod lint_cpp;
|
||||||
mod lint_docs;
|
mod lint_docs;
|
||||||
|
mod lint_repo_hygiene;
|
||||||
mod lint_text_format;
|
mod lint_text_format;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
@@ -16,12 +17,13 @@ use lint_cpp::{
|
|||||||
lint_boost_assert, lint_includes_build_config, lint_rpc_assert, lint_std_filesystem,
|
lint_boost_assert, lint_includes_build_config, lint_rpc_assert, lint_std_filesystem,
|
||||||
};
|
};
|
||||||
use lint_docs::{lint_doc_args, lint_doc_release_note_snippets, lint_markdown};
|
use lint_docs::{lint_doc_args, lint_doc_release_note_snippets, lint_markdown};
|
||||||
|
use lint_repo_hygiene::{lint_scripted_diff, lint_subtree};
|
||||||
use lint_text_format::{
|
use lint_text_format::{
|
||||||
lint_commit_msg, lint_tabs_whitespace, lint_trailing_newline, lint_trailing_whitespace,
|
lint_commit_msg, lint_tabs_whitespace, lint_trailing_newline, lint_trailing_whitespace,
|
||||||
};
|
};
|
||||||
use util::{
|
use util::{
|
||||||
check_output, commit_range, get_git_root, get_pathspecs_default_excludes, get_subtrees, git,
|
check_output, commit_range, get_git_root, get_pathspecs_default_excludes, git, LintFn,
|
||||||
LintFn, LintResult,
|
LintResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Linter {
|
struct Linter {
|
||||||
@@ -166,37 +168,6 @@ fn parse_lint_args(args: &[String]) -> Vec<&'static Linter> {
|
|||||||
lint_values
|
lint_values
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lint_subtree() -> LintResult {
|
|
||||||
// This only checks that the trees are pure subtrees, it is not doing a full
|
|
||||||
// check with -r to not have to fetch all the remotes.
|
|
||||||
let mut good = true;
|
|
||||||
for subtree in get_subtrees() {
|
|
||||||
good &= Command::new("test/lint/git-subtree-check.sh")
|
|
||||||
.arg(subtree)
|
|
||||||
.status()
|
|
||||||
.expect("command_error")
|
|
||||||
.success();
|
|
||||||
}
|
|
||||||
if good {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err("".to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn lint_scripted_diff() -> LintResult {
|
|
||||||
if Command::new("test/lint/commit-script-check.sh")
|
|
||||||
.arg(commit_range())
|
|
||||||
.status()
|
|
||||||
.expect("command error")
|
|
||||||
.success()
|
|
||||||
{
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err("".to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn lint_py_lint() -> LintResult {
|
fn lint_py_lint() -> LintResult {
|
||||||
let bin_name = "ruff";
|
let bin_name = "ruff";
|
||||||
let checks = format!(
|
let checks = format!(
|
||||||
@@ -257,9 +228,7 @@ fn lint_py_lint() -> LintResult {
|
|||||||
Ok(status) if status.success() => Ok(()),
|
Ok(status) if status.success() => Ok(()),
|
||||||
Ok(_) => Err(format!("`{bin_name}` found errors!")),
|
Ok(_) => Err(format!("`{bin_name}` found errors!")),
|
||||||
Err(e) if e.kind() == ErrorKind::NotFound => {
|
Err(e) if e.kind() == ErrorKind::NotFound => {
|
||||||
println!(
|
println!("`{bin_name}` was not found in $PATH, skipping those checks.");
|
||||||
"`{bin_name}` was not found in $PATH, skipping those checks."
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(e) => Err(format!("Error running `{bin_name}`: {e}")),
|
Err(e) => Err(format!("Error running `{bin_name}`: {e}")),
|
||||||
|
|||||||
Reference in new issue
Block a user