Skip to content

Commit 3bdf61e

Browse files
committed
Improve error when git not installed
1 parent b189820 commit 3bdf61e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

build/runner/src/build.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use std::io::Write;
77
use std::process::Command;
88
use std::time::Instant;
99

10+
use anki_process::CommandExt;
11+
use anyhow::Context;
1012
use camino::Utf8Path;
1113
use camino::Utf8PathBuf;
1214
use clap::Args;
@@ -162,11 +164,12 @@ fn maybe_update_buildhash(build_root: &Utf8Path) {
162164
fn get_buildhash() -> String {
163165
let output = Command::new("git")
164166
.args(["rev-parse", "--short=8", "HEAD"])
165-
.output()
166-
.expect("git");
167-
assert!(output.status.success(),
168-
"Invoking 'git' failed. Make sure you're building from a clone of the git repo, and that 'git' is installed.");
169-
String::from_utf8(output.stdout).unwrap().trim().into()
167+
.utf8_output()
168+
.context(
169+
"Make sure you're building from a clone of the git repo, and that 'git' is installed.",
170+
)
171+
.unwrap();
172+
output.stdout.trim().into()
170173
}
171174

172175
fn write_if_changed(path: &Utf8Path, contents: &str) {

0 commit comments

Comments
 (0)