diff --git a/src/main.rs b/src/main.rs index b700d3d..1292a13 100755 --- a/src/main.rs +++ b/src/main.rs @@ -95,6 +95,32 @@ fn main() { let matches = build_app().get_matches(); + if Path::exists("mlc.toml".as_ref()) && Path::exists(".git".as_ref()) { + info( + "In a git repository, pulling latest mlc.toml. It is advised you run mlc pull/update" + .to_string(), + ); + Command::new("git") + .arg("pull") + .spawn() + .unwrap() + .wait() + .unwrap(); + } + + if Path::exists("../.git".as_ref()) { + info("Parent directory is a git directory, pulling latest mlc.toml. It is advised you run mlc pull/update in all malachite directories".to_string()); + let dir = env::current_dir().unwrap(); + env::set_current_dir("../").unwrap(); + Command::new("git") + .arg("pull") + .spawn() + .unwrap() + .wait() + .unwrap(); + env::set_current_dir(dir).unwrap(); + } + if let true = matches.is_present("init") { let config = workspace::read_cfg(); if config.mode == "workspace" { @@ -127,12 +153,14 @@ fn main() { let mut packages: Vec = matches .subcommand_matches("build") .unwrap() - .values_of_lossy("package(s)").unwrap_or_default(); + .values_of_lossy("package(s)") + .unwrap_or_default(); let exclude: Vec = matches .subcommand_matches("build") .unwrap() - .values_of_lossy("exclude").unwrap_or_default(); + .values_of_lossy("exclude") + .unwrap_or_default(); for pkg in &exclude { packages.retain(|x| &*x != pkg); diff --git a/src/repository/package.rs b/src/repository/package.rs index c3df35c..57fe203 100755 --- a/src/repository/package.rs +++ b/src/repository/package.rs @@ -29,4 +29,4 @@ pub fn build(pkg: String) { .unwrap(); env::set_current_dir(dir).unwrap(); -} \ No newline at end of file +} diff --git a/src/repository/repo.rs b/src/repository/repo.rs index d8ca7fa..5dd750e 100644 --- a/src/repository/repo.rs +++ b/src/repository/repo.rs @@ -27,7 +27,13 @@ pub fn generate() { let files = format!("{}.files", &name); Command::new("bash") - .args(&["-c", &format!("repo-add {}.tar.gz *.pkg.tar.zst; repo-add {}.tar.gz *.pkg.tar.xz", db, db)]) + .args(&[ + "-c", + &format!( + "repo-add {}.tar.gz *.pkg.tar.zst; repo-add {}.tar.gz *.pkg.tar.xz", + db, db + ), + ]) .spawn() .unwrap() .wait() diff --git a/src/workspace/read.rs b/src/workspace/read.rs index a47b921..c1f08e0 100755 --- a/src/workspace/read.rs +++ b/src/workspace/read.rs @@ -38,4 +38,4 @@ pub fn read_cfg() -> Config { name: config.name, repo: expanded_repos, } -} \ No newline at end of file +}