Skip to content

feat(spm): support commit revisions - #11815

Merged
jdx merged 1 commit into
jdx:mainfrom
Marukome0743:pr11815
Aug 9, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
Marukome0743:pr11815

Conversation

@Marukome0743

@Marukome0743 Marukome0743 commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • support spm: installs pinned to rev:<commit> and compatible ref:<commit> selectors
  • build commit selectors from source without probing release artifact bundles
  • add revision-aware Git cloning so full and abbreviated commit IDs use a complete clone and detached checkout
  • document the new syntax and cover it with an actual two-commit Swift package

Root cause

The SPM backend passed the resolved tool version directly to Git::update_tag. For rev:<SHA>, this produced an invalid refs/tags/rev:<SHA> refspec instead of checking out the commit. It also attempted release artifact discovery even though a commit selector does not identify a release.

Behavior

Commit selectors now preserve rev-<SHA> or ref-<SHA> as the install identity while passing only the raw revision to Git. They always use the source-build path. Configurations that require artifact bundles fail early with a clear release-version error. Existing latest, release-tag, artifact-bundle, submodule, filter, and custom install-command behavior is unchanged.

Verification

  • mise exec -- cargo test --all-features backend::spm::tests
  • mise exec -- cargo test --all-features clone_by_sha_does_not_panic
  • mise run test:e2e e2e/core/test_swift_slow
  • mise exec -- cargo check --all-features
  • mise exec -- cargo clippy --workspace --all-features --all-targets -- -D warnings
  • Rustfmt, ShellCheck, shfmt, Prettier, and Markdown lint passed individually

mise run lint reaches the known hk limitation where this Sapling working copy is not recognized as a Git repository; all checks relevant to the changed files were run individually.

Addresses #4740

AI-assisted — Tool: Codex; model: OpenAI/GPT-5; version: unavailable.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

SPM now supports ref: and rev: commit selectors. Git revisions use direct clone and checkout flows, build from source, and avoid release artifact bundles. Tests cover full, abbreviated, and invalid revisions.

Changes

SPM Git revision support

Layer / File(s) Summary
Git revision checkout
src/git.rs, src/git.rs tests
CloneOptions supports explicit revisions. Clone paths check out full or abbreviated revisions and disable shallow cloning for explicit revisions.
SPM revision installation and validation
src/backend/spm.rs, e2e/core/test_swift_slow, docs/dev-tools/backends/spm.md
SPM distinguishes release versions from Git revisions, manages repository reuse and artifact-bundle handling, builds Git revisions from source, and documents supported selectors. Tests cover valid and invalid selectors.

Estimated code review effort: 4 (Complex) | ~45 minutes

Poem

A rabbit checks out commits in a row,
Full or short hashes tell where to go.
Source builds hop past bundles bright,
Bad revisions thump into the night.
SPM now follows Git just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for commit revisions in SPM.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

Actionable comments posted: 2

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

Inline comments:
In `@e2e/core/test_swift_slow`:
- Around line 38-50: Replace the persistent git config --global URL rewrite with
a test-local config file, and set GIT_CONFIG_GLOBAL only on the mise x, mise
install, and mise where commands that require it. Ensure the local configuration
is isolated to this test and does not affect later e2e tests.

In `@src/git.rs`:
- Around line 218-219: Update Git::checkout() to apply sanitize_git_env() before
invoking the git_cmd! checkout command, ensuring inherited GIT_DIR,
GIT_WORK_TREE, and GIT_INDEX_FILE cannot redirect it outside self.dir. Add a
regression test covering revision cloning with inherited Git work-tree
variables, including the checkout paths at both call sites.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 102fc68f-7f7e-415b-8166-70353a10bc41

📥 Commits

Reviewing files that changed from the base of the PR and between 95c9d83 and 89128ff.

📒 Files selected for processing (4)
  • docs/dev-tools/backends/spm.md
  • e2e/core/test_swift_slow
  • src/backend/spm.rs
  • src/git.rs

Comment thread e2e/core/test_swift_slow Resolved
Comment thread src/git.rs Resolved
@Marukome0743
Marukome0743 marked this pull request as ready for review August 9, 2026 23:36
@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds source-built Swift Package Manager installations pinned to rev:<commit> or compatible ref:<commit> selectors.

  • Distinguishes Git revisions from release versions during SPM installation.
  • Skips release artifact discovery for commit selectors and rejects incompatible artifact-only configurations.
  • Adds complete-clone and detached-checkout support for full and abbreviated revisions.
  • Documents the syntax and adds unit and end-to-end coverage.

Confidence Score: 5/5

The PR appears safe to merge with no actionable changed-code defects identified.

Commit selectors retain their installation identity while passing the raw revision to a complete Git clone and checkout, and incompatible artifact-only configurations are rejected before installation.

Important Files Changed

Filename Overview
src/backend/spm.rs Separates release and Git revisions, routes commit selectors through source builds, and preserves revision-aware cache identities.
src/git.rs Adds explicit revision clone semantics using a complete clone followed by checkout for full or abbreviated commit IDs.
e2e/core/test_swift_slow Adds a local two-commit Swift package test covering full and abbreviated revisions plus invalid revisions.
docs/dev-tools/backends/spm.md Documents commit selector syntax, source-build behavior, and artifact-bundle incompatibility.

Reviews (1): Last reviewed commit: "feat(spm): support commit revisions" | Re-trigger Greptile

@jdx
jdx merged commit a6b8ee7 into jdx:main Aug 9, 2026
31 checks passed
@Marukome0743
Marukome0743 deleted the pr11815 branch August 9, 2026 23:49
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.

2 participants