Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint against executable files in the root directory #98793

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/tools/tidy/src/bins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,25 @@ mod os_impl {

#[cfg(unix)]
pub fn check(path: &Path, bad: &mut bool) {
const ALLOWED: &[&str] = &["configure"];

crate::walk_no_read(
path,
&mut |path| crate::filter_dirs(path) || path.ends_with("src/etc"),
&mut |path| {
crate::filter_dirs(path)
|| path.ends_with("src/etc")
// This is a list of directories that we almost certainly
// don't need to walk. A future PR will likely want to
// remove these in favor of crate::walk_no_read using git
// ls-files to discover the paths we should check, which
// would naturally ignore all of these directories. It's
// also likely faster than walking the directory tree
// directly (since git is just reading from a couple files
// to produce the results).
|| path.ends_with("target")
|| path.ends_with("build")
jyn514 marked this conversation as resolved.
Show resolved Hide resolved
|| path.ends_with(".git")
},
&mut |entry| {
let file = entry.path();
let filename = file.file_name().unwrap().to_string_lossy();
Expand All @@ -110,6 +126,11 @@ mod os_impl {
if t!(is_executable(&file), file) {
let rel_path = file.strip_prefix(path).unwrap();
let git_friendly_path = rel_path.to_str().unwrap().replace("\\", "/");

if ALLOWED.contains(&git_friendly_path.as_str()) {
return;
}

let output = Command::new("git")
.arg("ls-files")
.arg(&git_friendly_path)
Expand Down
9 changes: 2 additions & 7 deletions src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,8 @@ fn main() {
check!(unit_tests, &compiler_path);
check!(unit_tests, &library_path);

if bins::check_filesystem_support(
&[&src_path, &compiler_path, &library_path],
&output_directory,
) {
check!(bins, &src_path);
check!(bins, &compiler_path);
check!(bins, &library_path);
if bins::check_filesystem_support(&[&root_path], &output_directory) {
check!(bins, &root_path);
}

check!(style, &src_path);
Expand Down
Binary file removed suggest-blanket-impl-local-trait
Binary file not shown.