diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-20 07:00:00 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-20 07:28:42 +0900 |
| commit | 1748a1e046cf6dd4ac02536c0f7fa26b3368e025 (patch) | |
| tree | 985bc5f37d227f4030eb7ec24350f8dc60309714 /crates/shirabe | |
| parent | 335c9c079b9215beb509bc298719733057aafd03 (diff) | |
| download | php-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')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/github_driver.rs | 17 | ||||
| -rw-r--r-- | crates/shirabe/tests/repository/vcs/github_driver_test.rs | 1 |
2 files changed, 9 insertions, 9 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), diff --git a/crates/shirabe/tests/repository/vcs/github_driver_test.rs b/crates/shirabe/tests/repository/vcs/github_driver_test.rs index 8b30a796..dfdbb01e 100644 --- a/crates/shirabe/tests/repository/vcs/github_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/github_driver_test.rs @@ -613,7 +613,6 @@ fn test_funding_format() { } } -#[ignore = "funding/archived parsing differs from PHP; not date-related"] #[test] fn test_public_repository_archived() { let SetUp { home, config } = set_up(); |
