diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-23 12:10:44 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-23 12:14:11 +0900 |
| commit | d8ecb21a7931ec6f1d7b447d0c15f53de32bfc45 (patch) | |
| tree | 0da1e0c2ec988905b98939b524b72217e83019de /crates/mozart-vcs/src/driver/svn.rs | |
| parent | 0080efea9386d46f65d1862fcb90eb44999d9761 (diff) | |
| download | php-mozart-d8ecb21a7931ec6f1d7b447d0c15f53de32bfc45.tar.gz php-mozart-d8ecb21a7931ec6f1d7b447d0c15f53de32bfc45.tar.zst php-mozart-d8ecb21a7931ec6f1d7b447d0c15f53de32bfc45.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-vcs/src/driver/svn.rs')
| -rw-r--r-- | crates/mozart-vcs/src/driver/svn.rs | 21 |
1 files changed, 12 insertions, 9 deletions
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<String, String>> { + async fn branches(&mut self) -> Result<&BTreeMap<String, String>> { 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<String, String>> { + async fn tags(&mut self) -> Result<&BTreeMap<String, String>> { 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<Option<serde_json::Value>> { + async fn composer_information( + &mut self, + identifier: &str, + ) -> Result<Option<serde_json::Value>> { 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<Option<String>> { + async fn file_content(&self, file: &str, identifier: &str) -> Result<Option<String>> { // 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<Option<String>> { + async fn change_date(&self, identifier: &str) -> Result<Option<String>> { 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<Option<DistReference>> { + async fn dist(&self, _identifier: &str) -> Result<Option<DistReference>> { // 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(()) } } |
