Skip to content

Commit 0cde870

Browse files
authored
feat(forge): Expand forge install error handling (foundry-rs#963)
* Fix .gitignore error in install_as_submodule * Handle unknown errors in install_as_submodule and install_as_folder * Run git in quiet mode to stop info messages from going to stderr * Replace .trim().split() with .lines() * Remove --quiet flags * Check exit status instead of stderr str length * Format
1 parent f097ed4 commit 0cde870

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cli/src/cmd/install.rs

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ fn install_as_folder(dep: &Dependency, libs: &Path) -> eyre::Result<()> {
102102
"Destination path \"{}\" already exists and is not an empty directory.",
103103
&dep.name
104104
)
105+
} else if !&output.status.success() {
106+
eyre::bail!("{}", stderr.trim())
105107
}
106108

107109
if let Some(ref tag) = dep.tag {
@@ -141,6 +143,12 @@ fn install_as_submodule(dep: &Dependency, libs: &Path, no_commit: bool) -> eyre:
141143
)
142144
} else if stderr.contains("not a git repository") {
143145
eyre::bail!("\"{}\" is not a git repository", &dep.url)
146+
} else if stderr.contains("paths are ignored by one of your .gitignore files") {
147+
let error =
148+
stderr.lines().filter(|l| !l.starts_with("hint:")).collect::<Vec<&str>>().join("\n");
149+
eyre::bail!("{}", error)
150+
} else if !&output.status.success() {
151+
eyre::bail!("{}", stderr.trim())
144152
}
145153

146154
// call update on it

0 commit comments

Comments
 (0)