diff options
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
10 files changed, 53 insertions, 58 deletions
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs index 35497d9..0c7e201 100644 --- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs +++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs @@ -718,12 +718,12 @@ impl crate::repository::vcs::VcsDriverInterface for ForgejoDriver { ForgejoDriver::get_tags(self) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(ForgejoDriver::get_dist(self, identifier)) + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + ForgejoDriver::get_dist(self, identifier) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(ForgejoDriver::get_source(self, identifier)) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + ForgejoDriver::get_source(self, identifier) } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs index 840a2ae..cf9a2ea 100644 --- a/crates/shirabe/src/repository/vcs/fossil_driver.rs +++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs @@ -402,12 +402,12 @@ impl crate::repository::vcs::VcsDriverInterface for FossilDriver { FossilDriver::get_tags(self) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(FossilDriver::get_dist(self, identifier)) + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + FossilDriver::get_dist(self, identifier) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(FossilDriver::get_source(self, identifier)) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + FossilDriver::get_source(self, identifier) } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index 45c0c68..875945a 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -481,10 +481,7 @@ impl GitBitbucketDriver { /// @inheritDoc pub fn get_source(&self, identifier: &str) -> IndexMap<String, String> { if let Some(fallback) = self.fallback_driver.as_ref() { - // TODO(phase-c): PHP getSource is infallible (: array), but the Rust trait made it - // anyhow::Result, so the fallback's anyhow::Result is flattened here. The faithful fix is making the - // VcsDriverInterface get_source/get_dist infallible across all implementations. - return fallback.get_source(identifier).unwrap_or_default(); + return fallback.get_source(identifier); } let mut m: IndexMap<String, String> = IndexMap::new(); @@ -500,8 +497,7 @@ impl GitBitbucketDriver { /// @inheritDoc pub fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { if let Some(fallback) = self.fallback_driver.as_ref() { - // TODO(phase-c): see get_source above — the trait's over-fallibility is flattened here. - return fallback.get_dist(identifier).ok().flatten(); + return fallback.get_dist(identifier); } let url = format!( @@ -751,15 +747,14 @@ impl GitBitbucketDriver { match self.setup_fallback_driver(&self.generate_ssh_url()) { Ok(()) => Ok(true), Err(e) => { - // TODO(phase-c): PHP catches \RuntimeException (and all its subclasses), letting - // other exceptions propagate without this cleanup. Modeling that precisely needs the - // PHP exception hierarchy, which is intentionally not reproduced (see CLAUDE.md). - self.fallback_driver = None; + if e.downcast_ref::<RuntimeException>().is_some() { + self.fallback_driver = None; - self.inner.io.write_error(&format!( - "<error>Failed to clone the {} repository, try running in interactive mode so that you can enter your Bitbucket OAuth consumer credentials</error>", - self.generate_ssh_url() - )); + self.inner.io.write_error(&format!( + "<error>Failed to clone the {} repository, try running in interactive mode so that you can enter your Bitbucket OAuth consumer credentials</error>", + self.generate_ssh_url() + )); + } Err(e) } } @@ -913,12 +908,12 @@ impl crate::repository::vcs::VcsDriverInterface for GitBitbucketDriver { GitBitbucketDriver::get_tags(self) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(GitBitbucketDriver::get_dist(self, identifier)) + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + GitBitbucketDriver::get_dist(self, identifier) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(GitBitbucketDriver::get_source(self, identifier)) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + GitBitbucketDriver::get_source(self, identifier) } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs index 186bfef..8111033 100644 --- a/crates/shirabe/src/repository/vcs/git_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_driver.rs @@ -527,12 +527,12 @@ impl crate::repository::vcs::VcsDriverInterface for GitDriver { GitDriver::get_tags(self) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(GitDriver::get_dist(self, identifier)) + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + GitDriver::get_dist(self, identifier) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(GitDriver::get_source(self, identifier)) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + GitDriver::get_source(self, identifier) } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index d68bf4e..3ee38f2 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -1350,19 +1350,19 @@ impl crate::repository::vcs::VcsDriverInterface for GitHubDriver { GitHubDriver::get_tags(self) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(GitHubDriver::get_dist(self, identifier).map(|m| { + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + GitHubDriver::get_dist(self, identifier).map(|m| { m.into_iter() .map(|(k, v)| (k, v.as_string().unwrap_or("").to_string())) .collect() - })) + }) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(GitHubDriver::get_source(self, identifier) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + GitHubDriver::get_source(self, identifier) .into_iter() .map(|(k, v)| (k, v.as_string().unwrap_or("").to_string())) - .collect()) + .collect() } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index 3f66223..4ad75b6 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -1156,19 +1156,19 @@ impl crate::repository::vcs::VcsDriverInterface for GitLabDriver { GitLabDriver::get_tags(self) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(GitLabDriver::get_dist(self, identifier).map(|m| { + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + GitLabDriver::get_dist(self, identifier).map(|m| { m.into_iter() .map(|(k, v)| (k, v.as_string().unwrap_or("").to_string())) .collect() - })) + }) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(GitLabDriver::get_source(self, identifier) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + GitLabDriver::get_source(self, identifier) .into_iter() .map(|(k, v)| (k, v.as_string().unwrap_or("").to_string())) - .collect()) + .collect() } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs index b668a2c..f987eb4 100644 --- a/crates/shirabe/src/repository/vcs/hg_driver.rs +++ b/crates/shirabe/src/repository/vcs/hg_driver.rs @@ -414,12 +414,12 @@ impl crate::repository::vcs::VcsDriverInterface for HgDriver { HgDriver::get_tags(self) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(HgDriver::get_dist(self, identifier)) + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + HgDriver::get_dist(self, identifier) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(HgDriver::get_source(self, identifier)) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + HgDriver::get_source(self, identifier) } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs index 55a8eae..9a98f4d 100644 --- a/crates/shirabe/src/repository/vcs/perforce_driver.rs +++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs @@ -269,19 +269,19 @@ impl crate::repository::vcs::VcsDriverInterface for PerforceDriver { PerforceDriver::get_tags(self) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(PerforceDriver::get_dist(self, identifier).map(|m| { + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + PerforceDriver::get_dist(self, identifier).map(|m| { m.into_iter() .map(|(k, v)| (k, v.as_string().unwrap_or("").to_string())) .collect() - })) + }) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(PerforceDriver::get_source(self, identifier) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + PerforceDriver::get_source(self, identifier) .into_iter() .map(|(k, v)| (k, v.as_string().unwrap_or("").to_string())) - .collect()) + .collect() } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index 7df7f02..50852ae 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -628,12 +628,12 @@ impl crate::repository::vcs::VcsDriverInterface for SvnDriver { Ok(self.get_tags()?.clone()) } - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>> { - Ok(SvnDriver::get_dist(self, identifier)) + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { + SvnDriver::get_dist(self, identifier) } - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { - Ok(SvnDriver::get_source(self, identifier)) + fn get_source(&self, identifier: &str) -> IndexMap<String, String> { + SvnDriver::get_source(self, identifier) } fn get_url(&self) -> String { diff --git a/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs b/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs index 5d2be04..fb10d0f 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs @@ -29,9 +29,9 @@ pub trait VcsDriverInterface: std::fmt::Debug { fn get_tags(&mut self) -> anyhow::Result<IndexMap<String, String>>; - fn get_dist(&self, identifier: &str) -> anyhow::Result<Option<IndexMap<String, String>>>; + fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>>; - fn get_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>>; + fn get_source(&self, identifier: &str) -> IndexMap<String, String>; fn get_url(&self) -> String; |
