aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-vcs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-03 11:55:03 +0900
committernsfisis <nsfisis@gmail.com>2026-05-03 11:55:03 +0900
commitae1aa6540761e54a76b8f7984cf93cd3a0d011d0 (patch)
treef111e1c73977f0bffb6323b03f4210269b43b297 /crates/mozart-vcs
parent30ae6c869adc7f3cb87a4d63edd6d0cda89d571d (diff)
downloadphp-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.tar.gz
php-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.tar.zst
php-mozart-ae1aa6540761e54a76b8f7984cf93cd3a0d011d0.zip
refactor: switch internal maps/sets from HashMap to IndexMap
Adopt indexmap workspace-wide so iteration order is deterministic and follows insertion order. The non-deterministic order of std HashMap otherwise leaks into resolver decisions when multiple valid solutions exist (e.g. cyclic require pairs under prefer-lowest), making behavior flaky and divergent from Composer's PHP-array semantics. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-vcs')
-rw-r--r--crates/mozart-vcs/Cargo.toml1
-rw-r--r--crates/mozart-vcs/src/driver/bitbucket.rs7
-rw-r--r--crates/mozart-vcs/src/driver/forgejo.rs7
-rw-r--r--crates/mozart-vcs/src/driver/git.rs9
-rw-r--r--crates/mozart-vcs/src/driver/github.rs7
-rw-r--r--crates/mozart-vcs/src/driver/gitlab.rs7
-rw-r--r--crates/mozart-vcs/src/driver/hg.rs7
-rw-r--r--crates/mozart-vcs/src/driver/svn.rs7
-rw-r--r--crates/mozart-vcs/src/process.rs8
9 files changed, 34 insertions, 26 deletions
diff --git a/crates/mozart-vcs/Cargo.toml b/crates/mozart-vcs/Cargo.toml
index dc6dfc3..18eff25 100644
--- a/crates/mozart-vcs/Cargo.toml
+++ b/crates/mozart-vcs/Cargo.toml
@@ -8,6 +8,7 @@ mozart-core.workspace = true
mozart-semver.workspace = true
anyhow.workspace = true
base64.workspace = true
+indexmap.workspace = true
regex.workspace = true
reqwest.workspace = true
serde.workspace = true
diff --git a/crates/mozart-vcs/src/driver/bitbucket.rs b/crates/mozart-vcs/src/driver/bitbucket.rs
index d47987d..77704fa 100644
--- a/crates/mozart-vcs/src/driver/bitbucket.rs
+++ b/crates/mozart-vcs/src/driver/bitbucket.rs
@@ -1,4 +1,5 @@
-use std::collections::{BTreeMap, HashMap};
+use indexmap::IndexMap;
+use std::collections::BTreeMap;
use anyhow::{Result, bail};
use regex::Regex;
@@ -16,7 +17,7 @@ pub struct BitbucketDriver {
root_identifier: Option<String>,
tags: Option<BTreeMap<String, String>>,
branches: Option<BTreeMap<String, String>>,
- info_cache: HashMap<String, Option<serde_json::Value>>,
+ info_cache: IndexMap<String, Option<serde_json::Value>>,
git_driver: Option<Box<GitDriver>>,
http_client: Client,
config: DriverConfig,
@@ -34,7 +35,7 @@ impl BitbucketDriver {
root_identifier: None,
tags: None,
branches: None,
- info_cache: HashMap::new(),
+ info_cache: IndexMap::new(),
git_driver: None,
http_client: Client::new(),
config,
diff --git a/crates/mozart-vcs/src/driver/forgejo.rs b/crates/mozart-vcs/src/driver/forgejo.rs
index ec2ca14..488e165 100644
--- a/crates/mozart-vcs/src/driver/forgejo.rs
+++ b/crates/mozart-vcs/src/driver/forgejo.rs
@@ -1,4 +1,5 @@
-use std::collections::{BTreeMap, HashMap};
+use indexmap::IndexMap;
+use std::collections::BTreeMap;
use anyhow::{Result, bail};
use regex::Regex;
@@ -20,7 +21,7 @@ pub struct ForgejoDriver {
root_identifier: Option<String>,
tags: Option<BTreeMap<String, String>>,
branches: Option<BTreeMap<String, String>>,
- info_cache: HashMap<String, Option<serde_json::Value>>,
+ info_cache: IndexMap<String, Option<serde_json::Value>>,
git_driver: Option<Box<GitDriver>>,
http_client: Client,
config: DriverConfig,
@@ -39,7 +40,7 @@ impl ForgejoDriver {
root_identifier: None,
tags: None,
branches: None,
- info_cache: HashMap::new(),
+ info_cache: IndexMap::new(),
git_driver: None,
http_client: Client::new(),
config,
diff --git a/crates/mozart-vcs/src/driver/git.rs b/crates/mozart-vcs/src/driver/git.rs
index cc9a210..43f4ecb 100644
--- a/crates/mozart-vcs/src/driver/git.rs
+++ b/crates/mozart-vcs/src/driver/git.rs
@@ -1,4 +1,5 @@
-use std::collections::{BTreeMap, HashMap};
+use indexmap::IndexMap;
+use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use anyhow::Result;
@@ -17,7 +18,7 @@ pub struct GitDriver {
root_identifier: Option<String>,
tags: Option<BTreeMap<String, String>>,
branches: Option<BTreeMap<String, String>>,
- info_cache: HashMap<String, Option<serde_json::Value>>,
+ info_cache: IndexMap<String, Option<serde_json::Value>>,
git_util: GitUtil,
is_local: bool,
}
@@ -37,7 +38,7 @@ impl GitDriver {
root_identifier: None,
tags: None,
branches: None,
- info_cache: HashMap::new(),
+ info_cache: IndexMap::new(),
git_util,
is_local,
}
@@ -85,7 +86,7 @@ impl GitDriver {
fn parse_tags(output: &str) -> BTreeMap<String, String> {
let mut tags = BTreeMap::new();
// First pass: collect dereferenced tags (^{})
- let mut dereferenced = HashMap::new();
+ let mut dereferenced = IndexMap::new();
for line in output.lines() {
let line = line.trim();
if line.is_empty() {
diff --git a/crates/mozart-vcs/src/driver/github.rs b/crates/mozart-vcs/src/driver/github.rs
index c47c2fe..9c11389 100644
--- a/crates/mozart-vcs/src/driver/github.rs
+++ b/crates/mozart-vcs/src/driver/github.rs
@@ -1,4 +1,5 @@
-use std::collections::{BTreeMap, HashMap};
+use indexmap::IndexMap;
+use std::collections::BTreeMap;
use anyhow::{Result, bail};
use regex::Regex;
@@ -19,7 +20,7 @@ pub struct GitHubDriver {
tags: Option<BTreeMap<String, String>>,
branches: Option<BTreeMap<String, String>>,
repo_data: Option<serde_json::Value>,
- info_cache: HashMap<String, Option<serde_json::Value>>,
+ info_cache: IndexMap<String, Option<serde_json::Value>>,
git_driver: Option<Box<GitDriver>>,
http_client: Client,
config: DriverConfig,
@@ -37,7 +38,7 @@ impl GitHubDriver {
tags: None,
branches: None,
repo_data: None,
- info_cache: HashMap::new(),
+ info_cache: IndexMap::new(),
git_driver: None,
http_client: Client::new(),
config,
diff --git a/crates/mozart-vcs/src/driver/gitlab.rs b/crates/mozart-vcs/src/driver/gitlab.rs
index f96c078..c1afbcb 100644
--- a/crates/mozart-vcs/src/driver/gitlab.rs
+++ b/crates/mozart-vcs/src/driver/gitlab.rs
@@ -1,4 +1,5 @@
-use std::collections::{BTreeMap, HashMap};
+use indexmap::IndexMap;
+use std::collections::BTreeMap;
use anyhow::{Result, bail};
use regex::Regex;
@@ -21,7 +22,7 @@ pub struct GitLabDriver {
root_identifier: Option<String>,
tags: Option<BTreeMap<String, String>>,
branches: Option<BTreeMap<String, String>>,
- info_cache: HashMap<String, Option<serde_json::Value>>,
+ info_cache: IndexMap<String, Option<serde_json::Value>>,
git_driver: Option<Box<GitDriver>>,
http_client: Client,
config: DriverConfig,
@@ -41,7 +42,7 @@ impl GitLabDriver {
root_identifier: None,
tags: None,
branches: None,
- info_cache: HashMap::new(),
+ info_cache: IndexMap::new(),
git_driver: None,
http_client: Client::new(),
config,
diff --git a/crates/mozart-vcs/src/driver/hg.rs b/crates/mozart-vcs/src/driver/hg.rs
index f884c50..0782775 100644
--- a/crates/mozart-vcs/src/driver/hg.rs
+++ b/crates/mozart-vcs/src/driver/hg.rs
@@ -1,4 +1,5 @@
-use std::collections::{BTreeMap, HashMap};
+use indexmap::IndexMap;
+use std::collections::BTreeMap;
use std::path::PathBuf;
use anyhow::Result;
@@ -17,7 +18,7 @@ pub struct HgDriver {
root_identifier: Option<String>,
tags: Option<BTreeMap<String, String>>,
branches: Option<BTreeMap<String, String>>,
- info_cache: HashMap<String, Option<serde_json::Value>>,
+ info_cache: IndexMap<String, Option<serde_json::Value>>,
hg_util: HgUtil,
config: DriverConfig,
}
@@ -31,7 +32,7 @@ impl HgDriver {
root_identifier: None,
tags: None,
branches: None,
- info_cache: HashMap::new(),
+ info_cache: IndexMap::new(),
hg_util: HgUtil::new(process),
config,
}
diff --git a/crates/mozart-vcs/src/driver/svn.rs b/crates/mozart-vcs/src/driver/svn.rs
index eea2d08..16363e1 100644
--- a/crates/mozart-vcs/src/driver/svn.rs
+++ b/crates/mozart-vcs/src/driver/svn.rs
@@ -1,4 +1,5 @@
-use std::collections::{BTreeMap, HashMap};
+use indexmap::IndexMap;
+use std::collections::BTreeMap;
use anyhow::Result;
use regex::Regex;
@@ -20,7 +21,7 @@ pub struct SvnDriver {
root_identifier: Option<String>,
tags: Option<BTreeMap<String, String>>,
branches: Option<BTreeMap<String, String>>,
- info_cache: HashMap<String, Option<serde_json::Value>>,
+ info_cache: IndexMap<String, Option<serde_json::Value>>,
svn_util: SvnUtil,
}
@@ -36,7 +37,7 @@ impl SvnDriver {
root_identifier: None,
tags: None,
branches: None,
- info_cache: HashMap::new(),
+ info_cache: IndexMap::new(),
svn_util: SvnUtil::new(process),
}
}
diff --git a/crates/mozart-vcs/src/process.rs b/crates/mozart-vcs/src/process.rs
index 91741a8..8ccc11d 100644
--- a/crates/mozart-vcs/src/process.rs
+++ b/crates/mozart-vcs/src/process.rs
@@ -1,4 +1,4 @@
-use std::collections::HashMap;
+use indexmap::IndexMap;
use std::path::Path;
use std::process::Command;
use std::time::{Duration, Instant};
@@ -18,7 +18,7 @@ pub struct ProcessOutput {
/// Corresponds to Composer's `ProcessExecutor`.
pub struct ProcessExecutor {
timeout: Option<Duration>,
- env_overrides: HashMap<String, Option<String>>,
+ env_overrides: IndexMap<String, Option<String>>,
}
impl Default for ProcessExecutor {
@@ -31,14 +31,14 @@ impl ProcessExecutor {
pub fn new() -> Self {
Self {
timeout: None,
- env_overrides: HashMap::new(),
+ env_overrides: IndexMap::new(),
}
}
pub fn with_timeout(secs: u64) -> Self {
Self {
timeout: Some(Duration::from_secs(secs)),
- env_overrides: HashMap::new(),
+ env_overrides: IndexMap::new(),
}
}