Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Simplify error handling with anyhow::Context
Maximilian Rooscdf28cd67a5f
diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rsindex ed438fb16..eeb20de21 100644--- a/src/git/repository/mod.rs+++ b/src/git/repository/mod.rs@@ -318,17 +318,10 @@ impl Repository {if self.is_bare()? {Ok(git_common_dir)} else {- git_common_dir+ Ok(git_common_dir.parent()- .ok_or_else(|| {- anyhow::Error::from(GitError::Other {- message: format!(- "Git directory has no parent: {}",- git_common_dir.display()- ),- })- })- .map(Path::to_path_buf)+ .context("Git directory has no parent")?+ .to_path_buf())}}).cloned()diff --git a/src/git/repository/remotes.rs b/src/git/repository/remotes.rsindex 918b018df..fa330ee03 100644--- a/src/git/repository/remotes.rs+++ b/src/git/repository/remotes.rs@@ -1,6 +1,8 @@//! Remote and URL operations for Repository.-use super::{GitError, GitRemoteUrl, Repository};+use anyhow::Context;++use super::{GitRemoteUrl, Repository};impl Repository {/// Get the primary remote name for this repository.@@ -114,14 +116,7 @@ impl Repository {let repo_name = repo_root.file_name().and_then(|name| name.to_str())- .ok_or_else(|| {- anyhow::Error::from(GitError::Other {- message: format!(- "Repository directory has no valid name: {}",- repo_root.display()- ),- })- })?;+ .context("Repository directory has no valid name")?;Ok(repo_name.to_string())})