@@ -1109,7 +1109,7 @@ impl GitRepository for RealGitRepository {
{
Ok(_) => anyhow::Ok(()),
Err(e) => {
- if let Some(git_error) = e.downcast_ref::<GitBranchCommandError>() {
+ if let Some(git_error) = e.downcast_ref::<GitBinaryCommandError>() {
anyhow::bail!("{}", git_error.stderr.trim());
}
Err(e)
@@ -1144,7 +1144,7 @@ impl GitRepository for RealGitRepository {
{
Ok(_) => Ok(()),
Err(e) => {
- if let Some(git_error) = e.downcast_ref::<GitBranchCommandError>() {
+ if let Some(git_error) = e.downcast_ref::<GitBinaryCommandError>() {
anyhow::bail!("{}", git_error.stderr.trim());
}
Err(e)
@@ -1881,7 +1881,7 @@ impl GitBinary {
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
if !output.status.success() {
- return Err(GitBranchCommandError {
+ return Err(GitBinaryCommandError {
stdout: stdout.clone(),
stderr: stderr.clone(),
status: output.status,
@@ -1933,14 +1933,6 @@ struct GitBinaryCommandError {
status: ExitStatus,
}
-#[derive(Error, Debug)]
-#[error("Git branch command failed: {}", .stderr.trim().if_empty(.stdout.trim()))]
-struct GitBranchCommandError {
- stdout: String,
- stderr: String,
- status: ExitStatus,
-}
-
trait StringExt {
fn if_empty<'a>(&'a self, fallback: &'a str) -> &'a str;
}