Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo lock tidy check #33404

Merged
merged 1 commit into from
May 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add a check to make tidy to ensure cargo lock file is updated
  • Loading branch information
gsquire committed May 4, 2016
commit b3de04214646a33fa5a14fbb2e8ba55e7ee5a707
33 changes: 6 additions & 27 deletions src/rustc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/tools/tidy/src/cargo_lock.rs
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;
}
}
});
}
2 changes: 2 additions & 0 deletions src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ mod style;
mod errors;
mod features;
mod cargo;
mod cargo_lock;

fn main() {
let path = env::args_os().skip(1).next().expect("need an argument");
Expand All @@ -46,6 +47,7 @@ fn main() {
errors::check(&path, &mut bad);
cargo::check(&path, &mut bad);
features::check(&path, &mut bad);
cargo_lock::check(&path, &mut bad);

if bad {
panic!("some tidy checks failed");
Expand Down