aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-08 04:22:49 +0900
committernsfisis <nsfisis@gmail.com>2026-06-08 04:23:11 +0900
commit632c9793927a30c4bca3c91888e66b369d732dfe (patch)
tree5bafb9d7fa2523d5a2f8d70ff59c3173e962e389 /crates/shirabe/src/repository/vcs
parent243450fee9853c2fea66ae0642dabb8db5227d6f (diff)
downloadphp-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.tar.gz
php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.tar.zst
php-shirabe-632c9793927a30c4bca3c91888e66b369d732dfe.zip
feat(phase-c): resolve PhpMixed-conversion phase-b TODOs
Implement the foundational PhpMixed conversion infrastructure (From<bool|i64|f64|String>, order-sensitive PartialEq matching PHP ===) and resolve the category-G phase-b TODOs that depend on it: - Fix VCS driver cache paths that discarded parsed JSON or diverged on null caches (svn/forgejo/gitlab/git-bitbucket/github). - Wire up real conversions previously stubbed or dropped: suggests platform config, audit ignore-severities, composer_repository search and ProviderInfo, class_loader prefix/classmap merges, locker lock diff comparison, advisory JSON serialization, SPDX license fields. - Make GenericRule take a typed ReasonData; populate RULE_ROOT_REQUIRE with the constraint and convert PhpMixed at the call sites.
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs7
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs16
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs1
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs15
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs20
5 files changed, 17 insertions, 42 deletions
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 3c1366d..a40f6a9 100644
--- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs
+++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
@@ -347,9 +347,10 @@ impl ForgejoDriver {
if !self.inner.info_cache.contains_key(identifier) {
let composer = if self.inner.should_cache(identifier) {
if let Some(res) = self.inner.cache.as_mut().and_then(|c| c.read(identifier)) {
- // TODO(phase-b): JsonFile::parse_json returns PhpMixed; convert into Option<IndexMap>
- let _ = JsonFile::parse_json(Some(res.as_str()), None)?;
- None
+ let parsed = JsonFile::parse_json(Some(res.as_str()), None)?;
+ parsed
+ .as_array()
+ .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect())
} else {
let file_content = self.get_file_content("composer.json", identifier)?;
let c = VcsDriverBase::finish_base_composer_information(
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index 3f0be13..f8cfd7a 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -239,7 +239,6 @@ impl GitBitbucketDriver {
.and_then(|v| v.as_string())
.map(String::from);
- // TODO(phase-b): unwrap PhpMixed::Array into the typed IndexMap stored on self
self.repo_data = match repo_data {
PhpMixed::Array(m) => m.into_iter().map(|(k, v)| (k, *v)).collect(),
_ => IndexMap::new(),
@@ -262,18 +261,9 @@ impl GitBitbucketDriver {
if self.inner.should_cache(identifier) && {
let res = self.inner.cache.as_mut().and_then(|c| c.read(identifier));
if let Some(res) = res {
- // TODO(phase-b): wrap parsed PhpMixed::Array into the IndexMap-shaped composer slot
- composer = Some(
- JsonFile::parse_json(Some(&res), None)?
- .as_array()
- .cloned()
- .map(|m| {
- m.into_iter()
- .map(|(k, v)| (k, *v))
- .collect::<IndexMap<String, PhpMixed>>()
- })
- .unwrap_or_default(),
- );
+ composer = JsonFile::parse_json(Some(&res), None)?
+ .as_array()
+ .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect());
true
} else {
false
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 6fc50ee..45ba7b7 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -279,7 +279,6 @@ impl GitHubDriver {
.as_mut()
.and_then(|c| c.read(identifier))
.unwrap_or_default();
- // TODO(phase-b): cached payload is JSON string; parse to PhpMixed -> Option<IndexMap>
let parsed = JsonFile::parse_json(Some(&res), None)?;
parsed
.as_array()
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
index 84961f5..97dcc30 100644
--- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs
+++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
@@ -275,18 +275,9 @@ impl GitLabDriver {
.as_mut()
.and_then(|c| c.read(identifier))
.unwrap_or_default();
- // TODO(phase-b): cached payload is wrapped to satisfy outer Option type
- Some(
- JsonFile::parse_json(Some(&res), None)?
- .as_array()
- .cloned()
- .map(|m| {
- m.into_iter()
- .map(|(k, v)| (k, *v))
- .collect::<IndexMap<String, PhpMixed>>()
- })
- .unwrap_or_default(),
- )
+ JsonFile::parse_json(Some(&res), None)?
+ .as_array()
+ .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect())
} else {
let file_content = self.get_file_content("composer.json", identifier)?;
let composer = VcsDriverBase::finish_base_composer_information(
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index 377d698..ef8787a 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -186,10 +186,13 @@ impl SvnDriver {
}
let parsed = JsonFile::parse_json(Some(res.as_str()), None)?;
- // TODO(phase-b): info_cache expects Option<IndexMap<String, PhpMixed>>;
- // PhpMixed → IndexMap conversion is non-trivial here. Skip insert/return.
- let _ = parsed;
- return Ok(None);
+ let composer: Option<IndexMap<String, PhpMixed>> = parsed
+ .as_array()
+ .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect());
+ self.inner
+ .info_cache
+ .insert(identifier.to_string(), composer.clone());
+ return Ok(composer);
}
}
@@ -253,15 +256,6 @@ impl SvnDriver {
.info_cache
.get(identifier)
.and_then(|v| v.clone());
- if cached.is_none()
- || !is_array(
- // TODO(phase-b): wrap IndexMap to PhpMixed for is_array check
- &cached.clone().map(PhpMixed::from).unwrap_or(PhpMixed::Null),
- )
- {
- return Ok(None);
- }
-
Ok(cached)
}