Skip to content

Commit

Permalink
Auto merge of #35848 - Mark-Simulacrum:make-tidy-in-tree, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors authored Aug 22, 2016
2 parents c44534e + be8df50 commit 57a1f68
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/tools/tidy/src/bins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub fn check(_path: &Path, _bad: &mut bool) {}
#[cfg(unix)]
pub fn check(path: &Path, bad: &mut bool) {
use std::fs;
use std::process::{Command, Stdio};
use std::os::unix::prelude::*;

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

let metadata = t!(fs::symlink_metadata(&file), &file);
if metadata.mode() & 0o111 != 0 {
println!("binary checked into source: {}", file.display());
*bad = true;
let rel_path = file.strip_prefix(path).unwrap();
let git_friendly_path = rel_path.to_str().unwrap().replace("\\", "/");
let ret_code = Command::new("git")
.arg("ls-files")
.arg(&git_friendly_path)
.current_dir(path)
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.unwrap_or_else(|e| {
panic!("could not run git ls-files: {}", e);
});
if ret_code.success() {
println!("binary checked into source: {}", file.display());
*bad = true;
}
}
})
}
Expand Down

0 comments on commit 57a1f68

Please sign in to comment.