Skip to content

Commit

Permalink
Improve diagnostics when fetching rev
Browse files Browse the repository at this point in the history
- suppress child stdout/stderr
- warn if rev is not found
  • Loading branch information
cmyr committed Sep 17, 2024
1 parent 4a46f54 commit 349f3e9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,20 @@ fn checkout_rev(repo_dir: &Path, rev: &str) -> Result<bool, GitFail> {
let _ = std::process::Command::new("git")
.current_dir(repo_dir)
.args(["fetch", "--unshallow"])
.status();
.output();

std::process::Command::new("git")
let result = std::process::Command::new("git")
.current_dir(repo_dir)
.arg("checkout")
.arg(rev)
.status()
.map(|stat| stat.success())
.map_err(Into::into)
.output()?;

if result.status.success() {
Ok(true)
} else {
log::warn!("failed to find rev {rev} for {}", repo_dir.display());
Ok(false)
}
}

fn load_metadata(path: &Path) -> Result<Metadata, MetadataError> {
Expand Down

0 comments on commit 349f3e9

Please sign in to comment.