From c028a9d5c737de5d2b259638a0a76b999364a262 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 6 Jun 2026 22:40:30 +0900 Subject: 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> and return Result, 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) --- .../src/repository/vcs/vcs_driver_interface.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/repository/vcs/vcs_driver_interface.rs') diff --git a/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs b/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs index c002dc5..e845300 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs @@ -12,19 +12,19 @@ pub trait VcsDriverInterface: std::fmt::Debug { fn initialize(&mut self) -> anyhow::Result<()>; fn get_composer_information( - &self, + &mut self, identifier: &str, ) -> anyhow::Result>>; - fn get_file_content(&self, file: &str, identifier: &str) -> anyhow::Result>; + fn get_file_content(&mut self, file: &str, identifier: &str) -> anyhow::Result>; - fn get_change_date(&self, identifier: &str) -> anyhow::Result>>; + fn get_change_date(&mut self, identifier: &str) -> anyhow::Result>>; - fn get_root_identifier(&self) -> anyhow::Result; + fn get_root_identifier(&mut self) -> anyhow::Result; - fn get_branches(&self) -> anyhow::Result>; + fn get_branches(&mut self) -> anyhow::Result>; - fn get_tags(&self) -> anyhow::Result>; + fn get_tags(&mut self) -> anyhow::Result>; fn get_dist(&self, identifier: &str) -> anyhow::Result>>; @@ -32,11 +32,16 @@ pub trait VcsDriverInterface: std::fmt::Debug { fn get_url(&self) -> String; - fn has_composer_file(&self, identifier: &str) -> anyhow::Result; + fn has_composer_file(&mut self, identifier: &str) -> anyhow::Result; fn cleanup(&mut self) -> anyhow::Result<()>; - fn supports(io: Rc>, config: &Config, url: &str, deep: bool) -> bool + fn supports( + io: Rc>, + config: Rc>, + url: &str, + deep: bool, + ) -> anyhow::Result where Self: Sized; } -- cgit v1.3.1