Skip to content

Commit be8df50

Browse files
Check that executable file is in-tree before failing tidy check.
1 parent f883b0b commit be8df50

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)