From d8ecb21a7931ec6f1d7b447d0c15f53de32bfc45 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 23 Feb 2026 12:10:44 +0900 Subject: refactor(vcs): convert VcsDriver trait to native async Replace manual tokio::runtime::Handle::current().block_on() calls with native async/await throughout all VCS drivers. Introduce AnyVcsDriver enum for static dispatch to avoid dyn trait with async methods. Co-Authored-By: Claude Opus 4.6 --- crates/mozart-vcs/src/driver/svn.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'crates/mozart-vcs/src/driver/svn.rs') diff --git a/crates/mozart-vcs/src/driver/svn.rs b/crates/mozart-vcs/src/driver/svn.rs index 8b47f75..eea2d08 100644 --- a/crates/mozart-vcs/src/driver/svn.rs +++ b/crates/mozart-vcs/src/driver/svn.rs @@ -74,7 +74,7 @@ impl SvnDriver { } impl VcsDriver for SvnDriver { - fn initialize(&mut self) -> Result<()> { + async fn initialize(&mut self) -> Result<()> { let info = self.svn_info(&self.url)?; if let Some(url) = info["url"].as_str() { self.base_url = url.to_string(); @@ -87,7 +87,7 @@ impl VcsDriver for SvnDriver { self.root_identifier.as_deref().unwrap_or("HEAD") } - fn branches(&mut self) -> Result<&BTreeMap> { + async fn branches(&mut self) -> Result<&BTreeMap> { if self.branches.is_none() { let mut branches = BTreeMap::new(); @@ -117,7 +117,7 @@ impl VcsDriver for SvnDriver { Ok(self.branches.as_ref().unwrap()) } - fn tags(&mut self) -> Result<&BTreeMap> { + async fn tags(&mut self) -> Result<&BTreeMap> { if self.tags.is_none() { let mut tags = BTreeMap::new(); let tags_url = format!("{}/{}", self.base_url, self.tags_path); @@ -136,18 +136,21 @@ impl VcsDriver for SvnDriver { Ok(self.tags.as_ref().unwrap()) } - fn composer_information(&mut self, identifier: &str) -> Result> { + async fn composer_information( + &mut self, + identifier: &str, + ) -> Result> { if let Some(cached) = self.info_cache.get(identifier) { return Ok(cached.clone()); } - let content = self.file_content("composer.json", identifier)?; + let content = self.file_content("composer.json", identifier).await?; let value = content.and_then(|c| serde_json::from_str(&c).ok()); self.info_cache .insert(identifier.to_string(), value.clone()); Ok(value) } - fn file_content(&self, file: &str, identifier: &str) -> Result> { + async fn file_content(&self, file: &str, identifier: &str) -> Result> { // identifier is either a path (trunk, branches/x, tags/y) or a revision number let url = if identifier.contains('/') || identifier == "trunk" { format!("{}/{}/{}", self.base_url, identifier, file) @@ -164,7 +167,7 @@ impl VcsDriver for SvnDriver { } } - fn change_date(&self, identifier: &str) -> Result> { + async fn change_date(&self, identifier: &str) -> Result> { let url = if identifier.contains('/') || identifier == "trunk" { format!("{}/{}", self.base_url, identifier) } else { @@ -176,7 +179,7 @@ impl VcsDriver for SvnDriver { } } - fn dist(&self, _identifier: &str) -> Result> { + async fn dist(&self, _identifier: &str) -> Result> { // SVN doesn't provide dist archives Ok(None) } @@ -193,7 +196,7 @@ impl VcsDriver for SvnDriver { &self.url } - fn cleanup(&mut self) -> Result<()> { + async fn cleanup(&mut self) -> Result<()> { Ok(()) } } -- cgit v1.3.1