forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#33404 - gsquire:cargo-lock, r=alexcrichton
Cargo lock tidy check A rebased PR for rust-lang#32901
- Loading branch information
Showing
3 changed files
with
51 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use std::path::Path; | ||
|
||
const CARGO_LOCK: &'static str = "Cargo.lock"; | ||
|
||
pub fn check(path: &Path, bad: &mut bool) { | ||
use std::process::Command; | ||
|
||
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 { | ||
let rel_path = file.strip_prefix(path).unwrap(); | ||
let ret_code = Command::new("git") | ||
.arg("diff-index") | ||
.arg("--quiet") | ||
.arg("HEAD") | ||
.arg(rel_path) | ||
.current_dir(path) | ||
.status() | ||
.unwrap_or_else(|e| { | ||
panic!("could not run git diff-index: {}", e); | ||
}); | ||
if !ret_code.success() { | ||
let parent_path = file.parent().unwrap().join("Cargo.toml"); | ||
print!("dirty lock file found at {} ", rel_path.display()); | ||
println!("please commit your changes or update the lock file by running:"); | ||
println!("\n\tcargo update --manifest-path {}", parent_path.display()); | ||
*bad = true; | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters