From 1748a1e046cf6dd4ac02536c0f7fa26b3368e025 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 20 Jul 2026 07:00:00 +0900 Subject: 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 --- crates/shirabe/src/repository/vcs/github_driver.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/repository/vcs/github_driver.rs') 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), -- cgit v1.3.1