Skip to content

fix(github): clean up static_helpers.rs and fix archive bin= option#7366

Merged
jdx merged 7 commits into
mainfrom
refactor/static-helpers-cleanup
Dec 17, 2025
Merged

fix(github): clean up static_helpers.rs and fix archive bin= option#7366
jdx merged 7 commits into
mainfrom
refactor/static-helpers-cleanup

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Dec 17, 2025

Summary

This PR combines functional fixes with code cleanup for src/backend/static_helpers.rs:

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

Registry updates:

  • Add GitHub backend for 6 tools: bosh-backup-and-restore, clusterawsadm, helm-diff, k3kcli, mdbook-linkcheck, opsgenie-lamp
  • Fix test commands for clusterawsadm and k3kcli to use correct binary names after bin= rename

This supersedes #7348 which had only the functional fixes.

Test plan

  • cargo build compiles successfully
  • All 8 unit tests in backend::static_helpers pass
  • All 6 updated tools pass mise test-tool:
    • bosh-backup-and-restore ✓
    • clusterawsadm ✓
    • helm-diff ✓
    • k3kcli ✓
    • mdbook-linkcheck ✓
    • opsgenie-lamp ✓

🤖 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.

  • Backend (static helpers):
    • Archive install: Support bin= for archives; search bin_path subdirs for bin/rename_exe; handle non-executable files in ZIPs by chmod+rename.
    • Refactors: Add lookup_with_fallback(); introduce should_skip_file() with skip lists; switch to file::ls/file::rename; add LazyLock-compiled VERSION_PATTERN; small helpers cleanup (e.g., extension reattachment).
    • Verification: Use platform fallback for checksum/size lookups.
  • Registry:
    • Add GitHub backends for bosh-backup-and-restore, clusterawsadm, helm-diff, k3kcli, mdbook-linkcheck, opsgenie-lamp.
    • Switch glab to gitlab: 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.

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>
Copilot AI review requested due to automatic review settings December 17, 2025 21:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_exe to search within bin_path subdirectories 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());
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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\"))

Suggested change
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")
});

Copilot uses AI. Check for mistakes.
}

// Check if filename matches tool name pattern or the target name
if file_name.contains(tool_name) || *file_name == *new_name {
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if file_name.contains(tool_name) || *file_name == *new_name {
if file_name.contains(tool_name) || file_name == new_name {

Copilot uses AI. Check for mistakes.
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>
@jdx jdx changed the title refactor(github): clean up static_helpers.rs and fix archive bin= option fix(github): clean up static_helpers.rs and fix archive bin= option Dec 17, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 17, 2025

Hyperfine Performance

mise x -- echo

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>
Comment thread src/backend/static_helpers.rs
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>
Comment thread src/backend/static_helpers.rs
claude and others added 2 commits December 17, 2025 22:29
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>
@jdx
Copy link
Copy Markdown
Owner Author

jdx commented Dec 17, 2025

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>
@jdx jdx enabled auto-merge (squash) December 17, 2025 22:53
@jdx jdx disabled auto-merge December 17, 2025 22:58
@jdx jdx merged commit 4a23ef8 into main Dec 17, 2025
33 of 35 checks passed
@jdx jdx deleted the refactor/static-helpers-cleanup branch December 17, 2025 22:58
jdx pushed a commit that referenced this pull request Dec 18, 2025
### 🚀 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)
jekis913 added a commit to jekis913/mise that referenced this pull request Dec 18, 2025
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants