aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-05 18:09:25 +0900
committernsfisis <nsfisis@gmail.com>2026-07-05 18:09:25 +0900
commit8aae17870a5ec2fdd9f0d4d61d33c792ff7b62b0 (patch)
tree4e589da29ead636082aeaaff4c674fd60227dcea /crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
parenta666f969ff42578ce583c481fb6093673203a924 (diff)
downloadphp-shirabe-8aae17870a5ec2fdd9f0d4d61d33c792ff7b62b0.tar.gz
php-shirabe-8aae17870a5ec2fdd9f0d4d61d33c792ff7b62b0.tar.zst
php-shirabe-8aae17870a5ec2fdd9f0d4d61d33c792ff7b62b0.zip
fix(git-bitbucket-driver): match PHP exception/fallibility semantics for fallback paths
VcsDriverInterface::get_source/get_dist were made fallible in the Rust port even though PHP's are infallible, forcing GitBitbucketDriver's fallback delegation to silently swallow errors via unwrap_or_default()/ok().flatten(). Make the trait infallible to match PHP, updating the mechanical Ok(...) wrapping in all implementors. Also narrow attempt_clone_fallback's cleanup to only trigger on RuntimeException, mirroring PHP's catch (\RuntimeException $e), using the same downcast pattern already used by has_composer_file for TransportException.
Diffstat (limited to 'crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs')
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs31
1 files changed, 13 insertions, 18 deletions
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 {