diff options
| author | bors <bors@rust-lang.org> | 2016-08-22 05:39:53 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-22 05:39:53 -0700 |
| commit | 57a1f684cd14d8f042b4356d8c1518ca3e02cecf (patch) | |
| tree | db0d953f8b21df0a01602569357c2c64c6152bf6 | |
| parent | c44534ef5a6b95cb032c6ce28c8893cf530903b9 (diff) | |
| parent | be8df50c9f3a8e9801ede314e6ab96395c349711 (diff) | |
| download | rust-57a1f684cd14d8f042b4356d8c1518ca3e02cecf.tar.gz rust-57a1f684cd14d8f042b4356d8c1518ca3e02cecf.zip | |
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.
| -rw-r--r-- | src/tools/tidy/src/bins.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/tools/tidy/src/bins.rs b/src/tools/tidy/src/bins.rs index e91b8fb0967..876ae404bba 100644 --- a/src/tools/tidy/src/bins.rs +++ b/src/tools/tidy/src/bins.rs @@ -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, @@ -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; + } } }) } |
