Skip to content

Commit 57a1f68

Browse files
authored
Auto merge of #35848 - Mark-Simulacrum:make-tidy-in-tree, r=alexcrichton
Check that executable file is in-tree before failing tidy check I silenced stdout and stderr for ls-files, not sure if that's appropriate (is `make tidy` intended to give debugging information)? Otherwise it prints each file it find to stdout/stderr, which currently prints nothing (only executable files are checked). I have not done major testing regarding the behavior of ls-files when the file is ignored, but judging by the man page everything should be fine. I've duplicated the code which makes the path git-friendly from the `Cargo.lock` checking code; I can extract that into a common helper if wanted (it's only two lines). Fixes #35689.
2 parents c44534e + be8df50 commit 57a1f68

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/tools/tidy/src/bins.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub fn check(_path: &Path, _bad: &mut bool) {}
2424
#[cfg(unix)]
2525
pub fn check(path: &Path, bad: &mut bool) {
2626
use std::fs;
27+
use std::process::{Command, Stdio};
2728
use std::os::unix::prelude::*;
2829

2930
super::walk(path,
@@ -37,8 +38,22 @@ pub fn check(path: &Path, bad: &mut bool) {
3738

3839
let metadata = t!(fs::symlink_metadata(&file), &file);
3940
if metadata.mode() & 0o111 != 0 {
40-
println!("binary checked into source: {}", file.display());
41-
*bad = true;
41+
let rel_path = file.strip_prefix(path).unwrap();
42+
let git_friendly_path = rel_path.to_str().unwrap().replace("\\", "/");
43+
let ret_code = Command::new("git")
44+
.arg("ls-files")
45+
.arg(&git_friendly_path)
46+
.current_dir(path)
47+
.stdout(Stdio::null())
48+
.stderr(Stdio::null())
49+
.status()
50+
.unwrap_or_else(|e| {
51+
panic!("could not run git ls-files: {}", e);
52+
});
53+
if ret_code.success() {
54+
println!("binary checked into source: {}", file.display());
55+
*bad = true;
56+
}
4257
}
4358
})
4459
}

0 commit comments

Comments
 (0)