aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-20 07:00:00 +0900
committernsfisis <nsfisis@gmail.com>2026-07-20 07:28:42 +0900
commit1748a1e046cf6dd4ac02536c0f7fa26b3368e025 (patch)
tree985bc5f37d227f4030eb7ec24350f8dc60309714 /crates/shirabe/src
parent335c9c079b9215beb509bc298719733057aafd03 (diff)
downloadphp-shirabe-1748a1e046cf6dd4ac02536c0f7fa26b3368e025.tar.gz
php-shirabe-1748a1e046cf6dd4ac02536c0f7fa26b3368e025.tar.zst
php-shirabe-1748a1e046cf6dd4ac02536c0f7fa26b3368e025.zip
fix(github-driver): defer get_branches until tags search misses
PHP's `?:` chain in getComposerInformation short-circuits, so getBranches() only runs when the tags search is falsy. The eager port issued an extra git/refs/heads API request that PHP never makes. Un-ignore test_public_repository_archived, which this fixes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 37bba1c7..94daf05c 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -326,9 +326,9 @@ impl GitHubDriver {
.map(|m| m.contains_key("source"))
.unwrap_or(false);
if support_source_missing {
+ // PHP's `?:` chain only evaluates getBranches() when the tags search is falsy.
let tags_map = self.get_tags()?;
- let branches_map = self.get_branches()?;
- let label = array_search_mixed(
+ let mut label = array_search_mixed(
&PhpMixed::String(identifier.to_string()),
&PhpMixed::Array(
tags_map
@@ -338,9 +338,10 @@ impl GitHubDriver {
),
false,
)
- .filter(|v| !matches!(v, PhpMixed::Bool(false) | PhpMixed::Null))
- .or_else(|| {
- array_search_mixed(
+ .filter(|v| !matches!(v, PhpMixed::Bool(false) | PhpMixed::Null));
+ if label.is_none() {
+ let branches_map = self.get_branches()?;
+ label = array_search_mixed(
&PhpMixed::String(identifier.to_string()),
&PhpMixed::Array(
branches_map
@@ -350,9 +351,9 @@ impl GitHubDriver {
),
false,
)
- })
- .filter(|v| !matches!(v, PhpMixed::Bool(false) | PhpMixed::Null))
- .unwrap_or_else(|| PhpMixed::String(identifier.to_string()));
+ .filter(|v| !matches!(v, PhpMixed::Bool(false) | PhpMixed::Null));
+ }
+ let label = label.unwrap_or_else(|| PhpMixed::String(identifier.to_string()));
let label_str = label.as_string().unwrap_or(identifier).to_string();
if let Some(support) = composer.get_mut("support").and_then(|v| match v {
PhpMixed::Array(m) => Some(m),