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/repository.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/repository.rs')
| -rw-r--r-- | crates/mozart-vcs/src/repository.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/mozart-vcs/src/repository.rs b/crates/mozart-vcs/src/repository.rs index 14f2ceb..b941eec 100644 --- a/crates/mozart-vcs/src/repository.rs +++ b/crates/mozart-vcs/src/repository.rs @@ -50,17 +50,17 @@ impl VcsRepository { /// 2. Reads composer.json from the root to get the package name /// 3. Scans tags → version releases /// 4. Scans branches → dev versions - pub fn scan(&self) -> Result<Vec<VcsPackageVersion>> { + pub async fn scan(&self) -> Result<Vec<VcsPackageVersion>> { let driver_type = self .driver_type .ok_or_else(|| anyhow::anyhow!("No suitable VCS driver found for URL: {}", self.url))?; let mut driver = create_driver(&self.url, driver_type, self.config.clone()); - driver.initialize()?; + driver.initialize().await?; // Get package name from root composer.json let root_id = driver.root_identifier().to_string(); - let root_info = driver.composer_information(&root_id)?; + let root_info = driver.composer_information(&root_id).await?; let package_name = match &root_info { Some(info) => info["name"] .as_str() @@ -81,14 +81,14 @@ impl VcsRepository { let mut versions = Vec::new(); // Scan tags - let tags = driver.tags()?.clone(); + let tags = driver.tags().await?.clone(); for (tag_name, tag_hash) in &tags { if let Some(version) = self.tag_to_version(tag_name) { - match driver.composer_information(tag_hash) { + match driver.composer_information(tag_hash).await { Ok(Some(info)) => { - let time = driver.change_date(tag_hash).unwrap_or(None); + let time = driver.change_date(tag_hash).await.unwrap_or(None); let source = driver.source(tag_hash); - let dist = driver.dist(tag_hash).unwrap_or(None); + let dist = driver.dist(tag_hash).await.unwrap_or(None); // Ensure name matches root package if info["name"].as_str() != Some(&package_name) { @@ -114,18 +114,18 @@ impl VcsRepository { } // Scan branches - let branches = driver.branches()?.clone(); + let branches = driver.branches().await?.clone(); let default_branch = driver.root_identifier().to_string(); for (branch_name, branch_hash) in &branches { - match driver.composer_information(branch_hash) { + match driver.composer_information(branch_hash).await { Ok(Some(info)) => { if info["name"].as_str() != Some(&package_name) { continue; } - let time = driver.change_date(branch_hash).unwrap_or(None); + let time = driver.change_date(branch_hash).await.unwrap_or(None); let source = driver.source(branch_hash); - let dist = driver.dist(branch_hash).unwrap_or(None); + let dist = driver.dist(branch_hash).await.unwrap_or(None); let is_default = branch_name == &default_branch; let version = self.branch_to_version(branch_name); @@ -154,7 +154,7 @@ impl VcsRepository { } } - driver.cleanup()?; + driver.cleanup().await?; Ok(versions) } |
