Skip to content

Commit

Permalink
Fix error when repository is in a detached HEAD state
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Ozias committed Oct 8, 2018
1 parent ff4b8f4 commit 39647c5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/output/envvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name>/HEAD file is.
Expand Down Expand Up @@ -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(())
Expand Down

0 comments on commit 39647c5

Please sign in to comment.