From b3908d08ee477f550dcb0e3d23305dee77e2258b Mon Sep 17 00:00:00 2001 From: Diggory Blake Date: Sat, 13 Aug 2016 22:36:04 +0100 Subject: [PATCH] Fix make-tidy lock file checks --- src/tools/tidy/src/cargo_lock.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tools/tidy/src/cargo_lock.rs b/src/tools/tidy/src/cargo_lock.rs index 4324db489b7f8..165dd52758ecc 100644 --- a/src/tools/tidy/src/cargo_lock.rs +++ b/src/tools/tidy/src/cargo_lock.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::path::Path; +use std::ffi::OsStr; const CARGO_LOCK: &'static str = "Cargo.lock"; @@ -18,14 +19,15 @@ pub fn check(path: &Path, bad: &mut bool) { super::walk(path, &mut |path| super::filter_dirs(path) || path.ends_with("src/test"), &mut |file| { - let name = file.file_name().unwrap().to_string_lossy(); - if name == CARGO_LOCK { + if let Some(CARGO_LOCK) = file.file_name().and_then(OsStr::to_str) { 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("diff-index") - .arg("--quiet") + .arg("diff") + .arg("--exit-code") + .arg("--patch") .arg("HEAD") - .arg(rel_path) + .arg(&git_friendly_path) .current_dir(path) .status() .unwrap_or_else(|e| {