From 39647c54609d2c9dd78e80d32a6a8cebbbf27c06 Mon Sep 17 00:00:00 2001 From: Jason Ozias Date: Mon, 8 Oct 2018 17:47:10 -0400 Subject: [PATCH] Fix error when repository is in a detached HEAD state --- src/output/envvar.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/output/envvar.rs b/src/output/envvar.rs index 08a3bdc3..b3475323 100644 --- a/src/output/envvar.rs +++ b/src/output/envvar.rs @@ -61,7 +61,7 @@ pub fn generate_cargo_keys(flags: ConstantsFlags) -> Fallible<()> { let git_refs_path = PathBuf::from(".git").join(current_head_file); println!("cargo:rerun-if-changed={}", git_refs_path.display()); } else { - return Err(failure::err_msg("Invalid HEAD file")); + eprintln!("You are most likely in a detached HEAD state"); } } else if metadata.is_file() { // We are in a worktree, so find out where the actual worktrees//HEAD file is. @@ -93,10 +93,12 @@ pub fn generate_cargo_keys(flags: ConstantsFlags) -> Fallible<()> { let git_refs_path = actual_git_dir.join(current_head_file); println!("cargo:rerun-if-changed={}", git_refs_path.display()); } else { - return Err(failure::err_msg("Invalid HEAD file")); + eprintln!("You are most likely in a detached HEAD state"); } } else { - return Err(failure::err_msg("Invalid .git format")); + return Err(failure::err_msg( + "Invalid .git format (Not a directory or a file)", + )); }; Ok(())