From da8b8546a3c1e9bdef1ee7d367cacdebd46d8ce0 Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 29 Jul 2022 09:45:56 +0100 Subject: [PATCH] Added early check for directory existing for git_info --- src/operations/info.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/operations/info.rs b/src/operations/info.rs index 1b61269..9e7658a 100644 --- a/src/operations/info.rs +++ b/src/operations/info.rs @@ -2,6 +2,7 @@ use colored::Colorize; use spinoff::{Color, Spinner, Spinners}; use std::env; use std::fmt::Write; +use std::path::Path; use std::process::Command; use tabled::Tabled; @@ -116,6 +117,17 @@ pub fn info(verbose: bool) { let mut repos_git = vec![]; if git_info { + // Crash early if directories are not found for git_info + for repo in &repos_unparsed { + if !Path::new(&repo.name).exists() { + crash!( + AppExitCode::RepoParseError, + "Failed to check directory {} for Git info, have you initialized the repo?", + repo.name, + ); + }; + } + // Start the spinner let sp = Spinner::new( Spinners::Line, @@ -133,7 +145,7 @@ pub fn info(verbose: bool) { \n\ # This script will run `git remote update` in all repositories\n\ pull() { cd $1; git remote update; cd -; }\n\ - \n" + \n", ); for repo in &repos_unparsed { writeln!(bash_script, "pull {} &", repo.name).unwrap();