fix(github): clean up static_helpers.rs and fix archive bin= option#7366
Conversation
This PR combines functional fixes with code cleanup: Functional fixes: - Add bin= option support for archive extraction (.tar.gz, .zip) - Fix rename_exe to search bin_path subdirectories when specified - Handle non-executable files in ZIP archives (chmod before rename) Refactoring: - Extract lookup_with_fallback() helper (replaces 9 duplicate patterns) - Extract should_skip_file() with SKIP_EXTENSIONS/SKIP_FILE_NAMES constants - Use file::ls() and file::rename() instead of std::fs equivalents - Add lazy regex compilation with LazyLock for VERSION_PATTERN - Add documentation to key functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors src/backend/static_helpers.rs while adding functional fixes for archive extraction. The changes consolidate duplicate code patterns, improve maintainability, and extend support for the bin= option to work with archives.
Key changes:
- Added
bin=option support for archive extraction, enabling binaries to be renamed during extraction - Fixed
rename_exeto search withinbin_pathsubdirectories when specified - Extracted common lookup pattern into
lookup_with_fallback()helper function to eliminate code duplication
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| /// Regex pattern for matching version suffixes like -v1.2.3, _1.2.3, etc. | ||
| static VERSION_PATTERN: LazyLock<regex::Regex> = | ||
| LazyLock::new(|| regex::Regex::new(r"[-_]v?\d+(\.\d+)*(-[a-zA-Z0-9]+(\.\d+)?)?$").unwrap()); |
There was a problem hiding this comment.
The unwrap() call on the regex compilation could panic if the regex pattern is invalid. Consider using expect() with a descriptive message to make debugging easier if this pattern ever needs to be modified: LazyLock::new(|| regex::Regex::new(r\"[-_]v?\\d+(\\.\\d+)*(-[a-zA-Z0-9]+(\\.\\d+)?)?$\").expect(\"VERSION_PATTERN regex must be valid\"))
| LazyLock::new(|| regex::Regex::new(r"[-_]v?\d+(\.\d+)*(-[a-zA-Z0-9]+(\.\d+)?)?$").unwrap()); | |
| LazyLock::new(|| { | |
| regex::Regex::new(r"[-_]v?\d+(\.\d+)*(-[a-zA-Z0-9]+(\.\d+)?)?$") | |
| .expect("VERSION_PATTERN regex must be valid") | |
| }); |
| } | ||
|
|
||
| // Check if filename matches tool name pattern or the target name | ||
| if file_name.contains(tool_name) || *file_name == *new_name { |
There was a problem hiding this comment.
The comparison *file_name == *new_name is comparing borrowed strings. This can be simplified to file_name == new_name without the explicit dereferences, which is more idiomatic Rust.
| if file_name.contains(tool_name) || *file_name == *new_name { | |
| if file_name.contains(tool_name) || file_name == new_name { |
Add GitHub backend as primary option for: - bosh-backup-and-restore - clusterawsadm - helm-diff - k3kcli - mdbook-linkcheck - opsgenie-lamp These tools now use the github backend with bin= and bin_path= options enabled by the static_helpers.rs changes in the previous commit. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.10 x -- echo |
19.9 ± 0.4 | 19.2 | 22.2 | 1.00 |
mise x -- echo |
20.7 ± 0.3 | 19.7 | 22.8 | 1.04 ± 0.03 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.10 env |
19.7 ± 0.5 | 18.9 | 23.6 | 1.00 |
mise env |
20.2 ± 0.5 | 18.8 | 21.3 | 1.03 ± 0.04 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.10 hook-env |
19.7 ± 0.4 | 18.9 | 20.8 | 1.00 |
mise hook-env |
20.2 ± 0.7 | 18.8 | 23.2 | 1.02 ± 0.04 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.12.10 ls |
16.7 ± 0.6 | 16.2 | 23.7 | 1.00 |
mise ls |
16.9 ± 0.2 | 16.3 | 18.0 | 1.01 ± 0.04 |
xtasks/test/perf
| Command | mise-2025.12.10 | mise | Variance |
|---|---|---|---|
| install (cached) | 108ms | 108ms | +0% |
| ls (cached) | 66ms | 66ms | +0% |
| bin-paths (cached) | 73ms | 73ms | +0% |
| task-ls (cached) | 298ms | 289ms | +3% |
Fix test commands for clusterawsadm and k3kcli to use the correct binary names after bin= option renames them: - clusterawsadm: cluster-api-provider-aws -> clusterawsadm - k3kcli: k3k -> k3kcli 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The bin= handler for archives was always searching in install_path, while rename_exe= correctly respected bin_path. This fix extracts the search_dir calculation to be shared by both handlers, ensuring consistent behavior when bin= and bin_path= are used together. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The tool_name from tv.ba().tool_name contains the full repo path like
"cloudfoundry-incubator/bosh-backup-and-restore", but binary filenames
are typically just the repo name (e.g., "bbr"). Extract just the repo
name using rsplit('/') so the second pass ZIP matching can find
binaries with different names.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
bugbot run |
- k3kcli: keep binary as k3k (not k3kcli) - clusterawsadm: keep binary as cluster-api-provider-aws (not clusterawsadm) - glab: revert unintended change from gitlab: to ubi: 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
### 🚀 Features - **(alias)** rename alias to tool-alias, add shell-alias command by @jdx in [#7357](#7357) - **(upgrade)** display summary of upgraded tools by @jdx in [#7372](#7372) - **(vfox)** embed vfox plugin Lua code in binary by @jdx in [#7369](#7369) ### 🐛 Bug Fixes - **(aqua)** add start_operations for progress reporting by @jdx in [#7354](#7354) - **(github)** improve asset detection for distro-specific and Swift artifacts by @jdx in [#7347](#7347) - **(github)** clean up static_helpers.rs and fix archive bin= option by @jdx in [#7366](#7366) - **(http)** add start_operations for progress reporting by @jdx in [#7355](#7355) - **(lockfile)** place lockfile alongside config file by @jdx in [#7360](#7360) - **(progress)** add start_operations to core plugins by @jdx in [#7351](#7351) - **(ruby-install)** Use ruby_install_bin to update by @calebhearth in [#7350](#7350) - **(rust)** add release_url for rust versions by @jdx in [#7373](#7373) - **(schema)** add `tool_alias`, mark `alias` as deprecated by @SKalt in [#7358](#7358) - **(toolset)** filter tools by OS in list_current_versions by @jdx in [#7356](#7356) - **(ubi)** only show deprecation warning during installation by @jdx in [#7380](#7380) - **(ui)** remove noisy "record size" message during install by @jdx in [#7381](#7381) - update mise-versions URL to use /tools/ prefix by @jdx in [#7378](#7378) ### 🚜 Refactor - **(backend)** unified AssetMatcher with checksum fetching by @jdx in [#7370](#7370) - **(backend)** deprecate ubi backend in favor of github by @jdx in [#7374](#7374) - **(toolset)** decompose mod.rs into smaller modules by @jdx in [#7371](#7371) ### 🧪 Testing - **(e2e)** fix and rename ubi and vfox_embedded_override tests by @jdx in [052ea40](052ea40) ### 📦 Registry - add vfox-gcloud backend for gcloud by @jdx in [#7349](#7349) - convert amplify to use github backend by @jdx in [#7365](#7365) - add github backend for djinni tool by @jdx in [#7363](#7363) - switch glab to native gitlab backend by @jdx in [#7364](#7364) - add s5cmd by @jdx in [#7376](#7376) ### Chore - **(registry)** disable flaky tests for gitu and ktlint by @jdx in [64151cb](64151cb) - resolve clippy warnings and add stricter CI check by @jdx in [#7367](#7367) - suppress dead_code warnings in asset_matcher module by @jdx in [#7377](#7377) ### New Contributors - @calebhearth made their first contribution in [#7350](#7350)
* upstream/main: fix(ui): remove noisy "record size" message during install (jdx#7381) test(e2e): fix and rename ubi and vfox_embedded_override tests fix: update mise-versions URL to use /tools/ prefix (jdx#7378) fix(ubi): only show deprecation warning during installation (jdx#7380) registry: add s5cmd (jdx#7376) chore: suppress dead_code warnings in asset_matcher module (jdx#7377) refactor(backend): deprecate ubi backend in favor of github (jdx#7374) fix(rust): add release_url for rust versions (jdx#7373) feat(vfox): embed vfox plugin Lua code in binary (jdx#7369) refactor(backend): unified AssetMatcher with checksum fetching (jdx#7370) feat(upgrade): display summary of upgraded tools (jdx#7372) fix(github): clean up static_helpers.rs and fix archive bin= option (jdx#7366) refactor(toolset): decompose mod.rs into smaller modules (jdx#7371) chore: resolve clippy warnings and add stricter CI check (jdx#7367) registry: switch glab to native gitlab backend (jdx#7364) fix(ruby-install): Use ruby_install_bin to update (jdx#7350) registry: add github backend for djinni tool (jdx#7363) registry: convert amplify to use github backend (jdx#7365) chore(registry): disable flaky tests for gitu and ktlint
Summary
This PR combines functional fixes with code cleanup for
src/backend/static_helpers.rs:Functional fixes:
bin=option support for archive extraction (.tar.gz, .zip)rename_exeto searchbin_pathsubdirectories when specifiedRefactoring:
lookup_with_fallback()helper (replaces 9 duplicate patterns)should_skip_file()withSKIP_EXTENSIONS/SKIP_FILE_NAMESconstantsfile::ls()andfile::rename()instead ofstd::fsequivalentsLazyLockforVERSION_PATTERNRegistry updates:
bin=renameThis supersedes #7348 which had only the functional fixes.
Test plan
cargo buildcompiles successfullybackend::static_helperspassmise test-tool:🤖 Generated with Claude Code
Note
Adds archive bin= support with smarter (bin_path-aware) renaming and ZIP exec handling, refactors option lookups/utilities, and updates registry backends for several tools.
bin=for archives; searchbin_pathsubdirs forbin/rename_exe; handle non-executable files in ZIPs by chmod+rename.lookup_with_fallback(); introduceshould_skip_file()with skip lists; switch tofile::ls/file::rename; addLazyLock-compiledVERSION_PATTERN; small helpers cleanup (e.g., extension reattachment).checksum/sizelookups.bosh-backup-and-restore,clusterawsadm,helm-diff,k3kcli,mdbook-linkcheck,opsgenie-lamp.glabtogitlab:backend; adjust tests/names where needed (e.g.,clusterawsadm,k3kcli).Written by Cursor Bugbot for commit 72e37dd. This will update automatically on new commits. Configure here.