diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-06 22:40:30 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-06 22:54:44 +0900 |
| commit | c028a9d5c737de5d2b259638a0a76b999364a262 (patch) | |
| tree | 36c7678a335d284e6d2139346660c77f1e124ddc /crates/shirabe/src/repository/vcs/svn_driver.rs | |
| parent | 33550b03c1724fbc8c1c8630c3b03fca1f0c0dc7 (diff) | |
| download | php-shirabe-c028a9d5c737de5d2b259638a0a76b999364a262.tar.gz php-shirabe-c028a9d5c737de5d2b259638a0a76b999364a262.tar.zst php-shirabe-c028a9d5c737de5d2b259638a0a76b999364a262.zip | |
feat(vcs): implement VcsDriverInterface for all VCS drivers
Reconcile the VcsDriverInterface trait with the concrete drivers so every
driver implements it as in PHP, where each driver extends VcsDriver.
- Make cache-mutating getters take &mut self in the trait, matching the
inherent methods' lazy-cache semantics; update vcs_repository consumers.
- Change supports() to take Rc<RefCell<Config>> and return Result<bool>,
completing GitDriver::supports deep ls-remote and its config wiring.
- Add base get_composer_information to Git/Hg/Fossil/Perforce and an
impl VcsDriverInterface block to every driver, delegating to inherent
methods and absorbing type differences in the impl.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/vcs/svn_driver.rs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/svn_driver.rs | 87 |
1 files changed, 79 insertions, 8 deletions
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index fc5abb9..3d344ec 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -481,18 +481,18 @@ impl SvnDriver { pub fn supports( io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, - _config: &Config, + _config: std::rc::Rc<std::cell::RefCell<Config>>, url: &str, deep: bool, - ) -> bool { + ) -> Result<bool> { let url = Self::normalize_url(url); if Preg::is_match(r"#(^svn://|^svn\+ssh://|svn\.)#i", &url).unwrap_or(false) { - return true; + return Ok(true); } // proceed with deep check for local urls since they are fast to process if !deep && !Filesystem::is_local_path(&url) { - return false; + return Ok(false); } let mut process = ProcessExecutor::new(Some(io)); @@ -511,24 +511,24 @@ impl SvnDriver { if exit == 0 { // This is definitely a Subversion repository. - return true; + return Ok(true); } // Subversion client 1.7 and older if stripos(&process.get_error_output(), "authorization failed:").is_some() { // This is likely a remote Subversion repository that requires // authentication. We will handle actual authentication later. - return true; + return Ok(true); } // Subversion client 1.8 and newer if stripos(&process.get_error_output(), "Authentication failed").is_some() { // This is likely a remote Subversion or newer repository that requires // authentication. We will handle actual authentication later. - return true; + return Ok(true); } - false + Ok(false) } /// An absolute path (leading '/') is converted to a file:// url. @@ -607,3 +607,74 @@ impl SvnDriver { ) } } + +impl crate::repository::vcs::VcsDriverInterface for SvnDriver { + fn initialize(&mut self) -> anyhow::Result<()> { + SvnDriver::initialize(self) + } + + fn get_composer_information( + &mut self, + identifier: &str, + ) -> anyhow::Result<Option<IndexMap<String, PhpMixed>>> { + SvnDriver::get_composer_information(self, identifier) + } + + fn get_file_content(&mut self, file: &str, identifier: &str) -> anyhow::Result<Option<String>> { + SvnDriver::get_file_content(self, file, identifier) + } + + fn get_change_date(&mut self, identifier: &str) -> anyhow::Result<Option<DateTime<Utc>>> { + SvnDriver::get_change_date(self, identifier) + } + + fn get_root_identifier(&mut self) -> anyhow::Result<String> { + Ok(SvnDriver::get_root_identifier(self)) + } + + fn get_branches(&mut self) -> anyhow::Result<IndexMap<String, String>> { + Ok(self.get_branches().clone()) + } + + fn get_tags(&mut self) -> anyhow::Result<IndexMap<String, String>> { + 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_source(&self, identifier: &str) -> anyhow::Result<IndexMap<String, String>> { + Ok(SvnDriver::get_source(self, identifier)) + } + + fn get_url(&self) -> String { + SvnDriver::get_url(self).to_string() + } + + fn has_composer_file(&mut self, identifier: &str) -> anyhow::Result<bool> { + match self.get_composer_information(identifier) { + Ok(info) => Ok(info.is_some()), + Err(e) => { + if e.downcast_ref::<TransportException>().is_some() { + Ok(false) + } else { + Err(e) + } + } + } + } + + fn cleanup(&mut self) -> anyhow::Result<()> { + Ok(()) + } + + fn supports( + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, + config: std::rc::Rc<std::cell::RefCell<Config>>, + url: &str, + deep: bool, + ) -> anyhow::Result<bool> { + SvnDriver::supports(io, config, url, deep) + } +} |
