From 8850997b5de3ea15ebfa53599cc2d05520a11210 Mon Sep 17 00:00:00 2001 From: Michal Date: Sun, 24 Jul 2022 16:10:30 +0100 Subject: [PATCH] Removed intrusive auto pulling of parent git repo --- src/main.rs | 51 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/src/main.rs b/src/main.rs index 622d63f..d9771f5 100755 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,6 @@ #![allow(clippy::too_many_lines)] use clap::Parser; -use std::env; -use std::path::Path; -use std::process::Command; use crate::args::{Args, Operation}; use crate::internal::parse_cfg; @@ -23,6 +20,7 @@ fn main() { crash!(AppExitCode::RunAsRoot, "Running malachite as root is disallowed as it can lead to system breakage. Instead, malachite will prompt you when it needs superuser permissions"); } + // Get required variables let args: Args = Args::parse(); let exclude = &args.exclude; let verbose = args.verbose; @@ -30,56 +28,15 @@ fn main() { log!(verbose, "Exclude: {:?}", exclude); log!(verbose, "Verbose: You guess. :)"); + // Parse config let config = parse_cfg(verbose); log!(verbose, "Config: {:?}", config); - if Path::exists("../.git".as_ref()) { - log!(verbose, "Detected parent git repository"); - info!("Parent directory is a git directory, pulling latest mlc.toml. It is advised you run mlc pull/update in all malachite directories"); - - let dir = env::current_dir().unwrap(); - env::set_current_dir("../").unwrap(); - log!(verbose, "Current dir: {:?}", env::current_dir().unwrap()); - - if config.base.smart_pull { - log!(verbose, "Smart pull"); - Command::new("git") - .args(&["remote", "update"]) - .spawn() - .unwrap() - .wait() - .unwrap(); - let output = Command::new("git").arg("status").output().unwrap(); - if String::from_utf8(output.stdout) - .unwrap() - .contains("Your branch is behind") - { - info!("Branch out of date, pulling changes"); - Command::new("git") - .arg("pull") - .spawn() - .unwrap() - .wait() - .unwrap(); - } else { - info!("No changes to pull"); - } - } else { - log!(verbose, "Normal pull"); - Command::new("git") - .arg("pull") - .spawn() - .unwrap() - .wait() - .unwrap(); - } - env::set_current_dir(dir).unwrap(); - log!(verbose, "Current dir: {:?}", env::current_dir().unwrap()); - } - + // Get repository mode status let repository = config.base.mode == "repository"; log!(verbose, "Repository Mode: {:?}", repository); + // Arg matching match args.subcommand.unwrap_or(Operation::Clone) { Operation::Clone => operations::clone(verbose), Operation::Build {