Skip to content

Commit 58cb885

Browse files
committed
give better context than an simple string
1 parent 8e57542 commit 58cb885

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/crates/git.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ impl CrateTrait for GitRepo {
8686
.cd(&path)
8787
.process_lines(&mut detect_private_repositories)
8888
.run()
89-
.with_context(|| format!("failed to update {}", self.url))
89+
.with_context(|| PrepareError::GitFailure {
90+
action: "update",
91+
url: self.url.clone(),
92+
})
9093
} else {
9194
info!("cloning repository {}", self.url);
9295
Command::new(workspace, "git")
@@ -95,7 +98,10 @@ impl CrateTrait for GitRepo {
9598
.args(&[&path])
9699
.process_lines(&mut detect_private_repositories)
97100
.run()
98-
.with_context(|| format!("failed to clone {}", self.url))
101+
.with_context(|| PrepareError::GitFailure {
102+
action: "clone",
103+
url: self.url.clone(),
104+
})
99105
};
100106

101107
if private_repository && res.is_err() {
@@ -118,7 +124,10 @@ impl CrateTrait for GitRepo {
118124
.args(&["clone"])
119125
.args(&[self.cached_path(workspace).as_path(), dest])
120126
.run()
121-
.with_context(|| format!("failed to checkout {}", self.url))?;
127+
.with_context(|| PrepareError::GitFailure {
128+
action: "checkout",
129+
url: self.url.clone(),
130+
})?;
122131
Ok(())
123132
}
124133
}

src/prepare.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,14 @@ pub enum PrepareError {
410410
/// cargo rejected the lockfile
411411
#[error("the crate has a broken lockfile: \n\n{0}")]
412412
InvalidCargoLock(String),
413+
/// git clone/fetch failed, but repository didn't appear to be private
414+
#[error("git failed to {action} for {url}")]
415+
GitFailure {
416+
/// action that was attempted
417+
action: &'static str,
418+
/// repo url
419+
url: String,
420+
},
413421
}
414422

415423
#[cfg(test)]

0 commit comments

Comments
 (0)