Skip to content

Commit f669017

Browse files
authored
fix(github): match arm assets on arm64 (#12098)
1 parent 7dc7520 commit f669017

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

src/backend/asset_matcher.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ static ARCH_PATTERNS: LazyLock<Vec<(AssetArch, Regex)>> = LazyLock::new(|| {
170170
]
171171
});
172172

173+
static BARE_ARM_PATTERN: LazyLock<Regex> =
174+
LazyLock::new(|| Regex::new(r"(?i)(?:\b|_)arm(?:\b|_)").unwrap());
175+
173176
static LIBC_PATTERNS: LazyLock<Vec<(AssetLibc, Regex)>> = LazyLock::new(|| {
174177
vec![
175178
(
@@ -524,6 +527,14 @@ impl AssetPicker {
524527
// this below a real x64/amd64 match so correctly named
525528
// assets win when both are present.
526529
5
530+
} else if *arch == AssetArch::Arm
531+
&& AssetArch::Arm64.matches_target(&self.target_arch)
532+
&& BARE_ARM_PATTERN.is_match(asset)
533+
{
534+
// Modern projects often use bare "arm" for their 64-bit ARM
535+
// artifacts. Keep this below a real arm64/aarch64 match, and
536+
// do not apply it to explicitly 32-bit armv0-armv7 assets.
537+
5
527538
} else {
528539
// Architecture mismatch should be disqualifying - don't silently
529540
// fall back to incompatible architectures (e.g., x86_64 when arm64
@@ -2729,6 +2740,42 @@ abc123def456abc123def456abc123def456abc123def456abc123def456abcd tool-darwin.ta
27292740
);
27302741
}
27312742

2743+
#[test]
2744+
fn test_arm_is_arm64_fallback() {
2745+
let assets = vec![
2746+
"elm-0.19.2-linux-arm.gz".to_string(),
2747+
"elm-0.19.2-mac-arm.gz".to_string(),
2748+
"elm-0.19.2-windows.exe".to_string(),
2749+
];
2750+
2751+
let macos_picker = AssetPicker::with_libc("macos".to_string(), "aarch64".to_string(), None);
2752+
assert_eq!(
2753+
macos_picker.pick_best_asset(&assets).as_deref(),
2754+
Some("elm-0.19.2-mac-arm.gz")
2755+
);
2756+
2757+
let linux_picker = AssetPicker::with_libc("linux".to_string(), "aarch64".to_string(), None);
2758+
assert_eq!(
2759+
linux_picker.pick_best_asset(&assets).as_deref(),
2760+
Some("elm-0.19.2-linux-arm.gz")
2761+
);
2762+
2763+
let explicit_assets = vec![
2764+
"tool-linux-arm.gz".to_string(),
2765+
"tool-linux-arm64.gz".to_string(),
2766+
];
2767+
assert_eq!(
2768+
linux_picker.pick_best_asset(&explicit_assets).as_deref(),
2769+
Some("tool-linux-arm64.gz")
2770+
);
2771+
2772+
assert!(
2773+
linux_picker
2774+
.pick_best_asset(&["tool-linux-armv7.gz".to_string()])
2775+
.is_none()
2776+
);
2777+
}
2778+
27322779
#[test]
27332780
fn test_arch_mismatch_rejected_after_positive_bonuses() {
27342781
let picker = AssetPicker::with_libc("linux".to_string(), "aarch64".to_string(), None)

0 commit comments

Comments
 (0)