about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorMark-Simulacrum <mark.simulacrum@gmail.com>2016-08-19 21:44:46 -0600
committerMark-Simulacrum <mark.simulacrum@gmail.com>2016-08-19 22:32:40 -0600
commitbe8df50c9f3a8e9801ede314e6ab96395c349711 (patch)
tree87ab4230d1398500af418bd7f918c9f13ef1e898 /src/tools
parentf883b0bbab6c433eb7b7042b605b4339022c563a (diff)
Check that executable file is in-tree before failing tidy check.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/tidy/src/bins.rs19
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;
+            }
         }
     })
 }