Skip to content

Commit

Permalink
Merge pull request #894 from gdesmott/git
Browse files Browse the repository at this point in the history
git: check return value from 'git' command
  • Loading branch information
EPashkin committed Apr 3, 2020
2 parents 56e8144 + 2445182 commit f42ad44
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ pub fn repo_hash<P: AsRef<Path>>(path: P) -> Option<String> {
None => vec![],
};
args.extend(&["rev-parse", "--short", "HEAD"]);
let hash = String::from_utf8(Command::new("git").args(&args).output().ok()?.stdout).ok()?;
let output = Command::new("git").args(&args).output().ok()?;
if !output.status.success() {
return None;
}
let hash = String::from_utf8(output.stdout).ok()?;
let hash = hash.trim_end_matches('\n');

if dirty(path) {
Expand Down

0 comments on commit f42ad44

Please sign in to comment.