Skip to content

refactor(file): rename TarFormat to ArchiveFormat#10275

Draft
risu729 wants to merge 3 commits into
jdx:mainfrom
risu729:refactor/archive-format-rename
Draft

refactor(file): rename TarFormat to ArchiveFormat#10275
risu729 wants to merge 3 commits into
jdx:mainfrom
risu729:refactor/archive-format-rename

Conversation

@risu729

@risu729 risu729 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • rename TarFormatArchiveFormat across extraction call sites
  • derive extension() from strum Display instead of a manual match

Depends on #10274.

Review note: After changing this PR's base branch to refactor/file-extraction-split (from risu729/mise), the diff is rename-only (~17 files). Until then the diff includes both stacked commits.

Test plan

  • cargo build --all-features
  • mise run lint-fix

Summary by CodeRabbit

  • Refactor
    • Unified archive handling infrastructure across the application with improved consistency in how different archive formats are processed and extracted.

Narrow untar to tar archives, add extract_archive and decompress_file,
and move format out of extraction options into per-call arguments.
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 281a9966-8fcd-4583-9dc7-752149855249

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR replaces a tar-specific extraction API (TarFormat/TarOptions) with a unified ArchiveFormat/ExtractOptions model across 18+ files. The core library refactor introduces format-agnostic extraction routing, decompression utilities, and updated helper functions, then systematically updates backend and plugin consumers to use the new API.

Changes

Archive Format API Unification

Layer / File(s) Summary
ArchiveFormat enum and parsing
src/file.rs
Introduces ArchiveFormat enum with variants for tar-family, zip, 7z, compressed single-file, and raw formats; implements parsing from filename/extension (including multi-part .tar.*) and classification predicates (is_archive(), is_tar_archive(), is_compressed_single_file()).
Core extraction dispatcher and decompression
src/file.rs
Adds decompress_file(input, dest, format) for single-file decompression; introduces ExtractOptions struct; refactors extract_archive routing to dispatch tar/zip/7z extraction or reject compressed single-file formats; updates untar to accept ArchiveFormat and ExtractOptions with destination directory creation and post-extraction path stripping.
Archive inspection and content helpers
src/file.rs
Updates open_tar to accept ArchiveFormat and reject unsupported formats with targeted errors; refactors inspect_tar_contents and should_strip_components parameter types; updates archive_content_files and archive_content_files_tar to route tar vs zip enumeration and reject 7z/compressed single-file formats; adds unit tests for format parsing, decompress_file, extract_archive with zip, untar error handling, and strip_components.
Backend extraction paths
src/backend/aqua.rs, src/backend/http.rs, src/backend/github.rs, src/backend/spm.rs, src/backend/static_helpers.rs, src/cli/generate/tool_stub.rs, src/backend/asset_matcher.rs
Aqua special-cases dmg/pkg and routes compressed/archive formats through unified decompress_file/extract_archive; HTTP refactors FileInfo detection and extraction dispatcher; GitHub/SPM/static_helpers/tool_stub update archive format parsing and extraction calls; asset_matcher updates format scoring; all wire through progress reporters and strip_components.
Plugin extraction paths
src/plugins/asdf_plugin.rs, src/plugins/core/{erlang,go,java,node,python,ruby,swift,zig}.rs, src/plugins/vfox_plugin.rs
Most plugins switch from TarFormat/TarOptions to ArchiveFormat::TarGz/ExtractOptions with consistent strip_components and progress reporter wiring; Java and Python use generic extract_archive for format flexibility; asdf/ruby/vfox update ZIP strip_components detection to use ArchiveFormat::Zip.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • jdx/mise#10224: Updates aqua.rs to route Windows 7z archives through the unified extraction flow, directly supporting the main PR's ArchiveFormat refactoring.

Poem

🐰 Formats unified, no more tar alone,
ArchiveFormat now rules the extraction throne,
Zip, 7z, and gzip join the dance so grand,
One API to extract them all, across the land!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and concisely summarizes the main refactoring: renaming TarFormat to ArchiveFormat across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@risu729 risu729 marked this pull request as draft June 8, 2026 22:52
@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR renames TarFormatArchiveFormat and TarOptionsExtractOptions (with format moved out of the options struct into a separate parameter), derives extension() from strum Display instead of a manual match, and introduces decompress_file(), is_tar_archive(), and is_compressed_file() helpers to cleanly separate single-file decompression from archive extraction.

  • src/file.rs: Core refactor — ArchiveFormat enum, new decompress_file() public function, extract_archive() dispatcher, untar() now accepts format explicitly and guards against non-tar inputs; extension() now returns Option<String> via strum Display (first serializer); tbz alias added for TarBz2.
  • src/backend/aqua.rs: Replaces manual format if-else chain with is_compressed_file() / extract_archive() routing; GithubArchive type promotes Raw → TarGz before extraction.
  • Remaining files (http.rs, static_helpers.rs, spm.rs, java.rs, plugin files): Mechanical rename of types and call-site updates to pass ArchiveFormat and ExtractOptions separately.

Confidence Score: 5/5

Safe to merge — this is a mechanical rename with well-contained behavioral changes that preserve existing semantics throughout the call graph.

The rename is consistent across all 18 files. The extension() method switch from Option<&'static str> to Option via strum Display correctly uses the first serializer for every variant, matching the original hand-written match. Single-file decompression is properly migrated to the new decompress_file() helper. The untar() guard against non-tar formats is a correctness improvement. Behavioral changes in aqua.rs were already noted in prior review rounds.

No files require special attention beyond what was already flagged in previous review rounds.

Important Files Changed

Filename Overview
src/file.rs Core refactor: renames TarFormat→ArchiveFormat, splits TarOptions→ExtractOptions (format separated out), adds decompress_file(), is_tar_archive(), is_compressed_file() helpers; extension() now derives from strum Display returning Option; untar() now guards against non-tar formats; new tests added
src/backend/aqua.rs Replaces manual format dispatch with extract_archive/decompress_file; unknown formats now fall through to extract_archive(Raw) instead of bailing (pre-existing concern, previously flagged)
src/backend/http.rs Mechanical rename: TarFormat→ArchiveFormat, TarOptions→ExtractOptions; compress-binary path now uses decompress_file(), archive path uses extract_archive(); extension() call simplified
src/backend/static_helpers.rs Mechanical rename; compressed-binary path now calls decompress_file(), archive path calls extract_archive() with format passed separately
src/cli/generate/tool_stub.rs Replaces TarOptions/untar with ExtractOptions/extract_archive; ArchiveFormat::from_file_name computed twice (second shadows first — previously flagged)
src/backend/spm.rs Simplifies zip extraction: replaces untar(..., TarFormat::Zip, ...) with direct file::unzip() call
src/plugins/core/java.rs Unifies zip/non-zip dispatch: derives ArchiveFormat from file_type then filename fallback and routes through extract_archive()
src/backend/asset_matcher.rs Mechanical rename: TarFormat→ArchiveFormat in score_format_preferences()
src/backend/github.rs Mechanical rename: TarFormat::from_ext/from_file_name → ArchiveFormat equivalents
src/plugins/asdf_plugin.rs Mechanical rename: TarFormat::Zip → ArchiveFormat::Zip in should_strip_components call
src/plugins/vfox_plugin.rs Mechanical rename: TarFormat::Zip → ArchiveFormat::Zip in should_strip_components call

Reviews (2): Last reviewed commit: "refactor(file): rename TarFormat to Arch..." | Re-trigger Greptile

@risu729 risu729 force-pushed the refactor/archive-format-rename branch from 71772f4 to d041688 Compare June 8, 2026 22:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/backend/aqua.rs (1)

2283-2312: Reassess risk: GithubArchive skips chmod +x, relying on tar-extracted mode bits

  • In src/backend/aqua.rs (AquaPackageType::GithubArchive), make_executable stays false, so the later file::make_executable(...) loop (which does chmod +x) is not run; it only runs for GithubContent/raw and other archive paths.
  • GithubArchive downloads source as .../archive/refs/tags/{v}.tar.gz, and file::extract_archive(...) routes TarGz to untar(...), which extracts file permissions from the tar headers (so skipping chmod +x should still preserve executability when the git repo marks files executable).
  • Remaining risk is only for cases where the archive contains non-executable binaries but mise expects them to be runnable; the registry has 8 top-level type: github_archive packages (b3nj5m1n/xdg-ninja, bats-core/bats-core, iamhsa/pkenv, npryce/adr-tools, shellspec/shellspec, tfutils/tfenv, tgenv/tgenv, tofuutils/tofuenv).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/backend/aqua.rs` around lines 2283 - 2312, The GithubArchive branch
currently calls file::extract_archive(...) but leaves the local flag
make_executable false so the subsequent file::make_executable(...) loop is
skipped; to avoid missing chmod for archives whose tar headers don't mark
executables, set make_executable = true in the AquaPackageType::GithubArchive
branch (or otherwise ensure the post-extract call to file::make_executable(...)
runs) so files copied/extracted by file::extract_archive(...) get the same chmod
treatment as the GithubContent/raw/archive paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/backend/aqua.rs`:
- Around line 2283-2312: The GithubArchive branch currently calls
file::extract_archive(...) but leaves the local flag make_executable false so
the subsequent file::make_executable(...) loop is skipped; to avoid missing
chmod for archives whose tar headers don't mark executables, set make_executable
= true in the AquaPackageType::GithubArchive branch (or otherwise ensure the
post-extract call to file::make_executable(...) runs) so files copied/extracted
by file::extract_archive(...) get the same chmod treatment as the
GithubContent/raw/archive paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 70287caa-a398-4dc6-bfbb-0af4b9d9fa17

📥 Commits

Reviewing files that changed from the base of the PR and between 5ceaa53 and 71772f4.

📒 Files selected for processing (18)
  • src/backend/aqua.rs
  • src/backend/asset_matcher.rs
  • src/backend/github.rs
  • src/backend/http.rs
  • src/backend/spm.rs
  • src/backend/static_helpers.rs
  • src/cli/generate/tool_stub.rs
  • src/file.rs
  • src/plugins/asdf_plugin.rs
  • src/plugins/core/erlang.rs
  • src/plugins/core/go.rs
  • src/plugins/core/java.rs
  • src/plugins/core/node.rs
  • src/plugins/core/python.rs
  • src/plugins/core/ruby.rs
  • src/plugins/core/swift.rs
  • src/plugins/core/zig.rs
  • src/plugins/vfox_plugin.rs

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

This PR currently has failing checks. If this continues for 7 days, it will be closed automatically.

This is warning day 1 of 7.

Please update the PR when you have a chance. Feel free to reopen or create a new PR if it is closed and you'd like to continue working on it.

This comment was generated by an automated workflow.

@github-actions

Copy link
Copy Markdown

This PR currently has failing checks. If this continues for 7 days, it will be closed automatically.

This is warning day 2 of 7.

Please update the PR when you have a chance. Feel free to reopen or create a new PR if it is closed and you'd like to continue working on it.

This comment was generated by an automated workflow.

@github-actions

Copy link
Copy Markdown

This PR currently has failing checks. If this continues for 7 days, it will be closed automatically.

This is warning day 3 of 7.

Please update the PR when you have a chance. Feel free to reopen or create a new PR if it is closed and you'd like to continue working on it.

This comment was generated by an automated workflow.

@github-actions

Copy link
Copy Markdown

This PR currently has failing checks. If this continues for 7 days, it will be closed automatically.

This is warning day 4 of 7.

Please update the PR when you have a chance. Feel free to reopen or create a new PR if it is closed and you'd like to continue working on it.

This comment was generated by an automated workflow.

@github-actions

Copy link
Copy Markdown

This PR currently has failing checks and merge conflicts. If this continues for 7 days, it will be closed automatically.

This is warning day 5 of 7.

Please update the PR when you have a chance. Feel free to reopen or create a new PR if it is closed and you'd like to continue working on it.

This comment was generated by an automated workflow.

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.

1 participant