Repository navigation
Fix vendored gem directories losing files git ignores (#2348) - #2451
Mikola Lysenko (mikolalysenko) merged 7 commits into
Conversation
Refs #2348. Assisted-by: Claude Code:claude-fable-5-2
Four of the five cases fail on main: a file of a plain gem's vendored directory that an ignore rule matches is left out of the commit, a rule that ignores the vendored dir is not refused, a .gitignore the gem ships keeps its rules, and the uuid dir gets no git metadata. The fifth pins what repair does for a copy vendored before the fix. Refs #2348. Assisted-by: Claude Code:claude-fable-5-2
A gem vendored as its own directory got none of the ignore handling a gem vendored as platform gems has, so a project rule (the .rspec of GitHub's Rails.gitignore) or a .gitignore the gem ships left files of the copy out of the commit. Every fresh clone then failed vendor --check and vex with vendor_inventory_mismatch. Every vendored gem now gets the uuid dir's .gitignore and .gitattributes, has the .gitignore files it ships emptied in the copy, and is refused (vendor_artifact_gitignored) when git would still leave a file out. An in-sync re-run and repair put the pair back. Repair keeps a shipped .gitignore that the ledger inventory of an earlier release recorded, so such a copy still verifies. Refs #2348. Assisted-by: Claude Code:claude-fable-5-2
A real-Bundler case commits and clones a project whose .gitignore has the .rspec rule of GitHub's Rails.gitignore, with a gem that ships that file (diff-lcs 1.5.1). The clone holds the whole copy, vendor --check passes there, and a frozen bundle install loads the patched gem. It fails against main's backend. The CLI contract and the ecosystem guide now describe the uuid dir's git metadata and the emptied .gitignore for every vendored gem. Refs #2348. Assisted-by: Claude Code:claude-fable-5-2
Review findings on the vendored gem dir fix. A gem can ship a .gitignore as data (a template it copies into new projects). In a gem's own tree only a .gitignore whose rules match a file of the copy is emptied now; the rest stay byte for byte. Repair restores each one as the ledger inventory records it. A copy that an earlier release vendored keeps the gem's .gitignore as shipped. The in-sync run that writes the uuid dir's pair for it now warns vendor_gem_copy_gitignored when git would still leave a file out, and names git add -f. Repair writes the pair for a healthy copy too, as the docs say. The check for a rule that ignores the uuid dir moved behind the Bazel hub branch, so a gem committed as its archive is asked what it was asked before. Refs #2348. Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview The gem backend neutralizes only shipped Docs and contract rows were updated ( Reviewed by Cursor Bugbot for commit 8900ea7. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8900ea7. Configure here.
The check for whether a .gitignore the gem ships hides a file asked about the file before its directories, so a negation looked like it re-included a file under an ignored directory. Git never looks inside such a directory. The copy then kept that .gitignore, and the fresh vendor refused the gem where it could have emptied the file. Directories are now asked top-down, first match settles it. Refs #2348. Assisted-by: Claude Code:claude-fable-5-2
Both sides appended a test to e2e_vendor_gem_build.rs; both are kept. Assisted-by: Claude Code:claude-fable-5-2

LLM Description written by Claude Code:claude-fable-5-2
Refs #2348
Summary
A gem vendored as its own directory (
.socket/vendor/gem/<uuid>/<name>-<version>/) could lose files at commit. A project ignore rule (the.rspecline of GitHub'sRails.gitignore) or a.gitignoreshipped inside the gem kept files of the copy out of git. The checkout that vendored the gem verified; every fresh clone failedvendor --checkandvexwithvendor_inventory_mismatch.This PR gives the plain gem directory the handling that a gem vendored as platform gems already has:
.gitignore(!*) and the shared.gitattributes, so project rules and filters do not apply below it..gitignorethe gem ships is emptied in the copy when its rules match a file of the copy (vendor_gem_gitignore_neutralized). One that hides nothing is kept byte for byte, because a gem can ship one as data (Jekyll's site template). One the patch rewrites is kept.vendor_artifact_gitignoredbefore any download, dry run included. After the copy is written, git is asked about every file, and the gem is refused and unwound if one would still be left out.repairwrite the pair when it is missing, which is how a copy vendored by an earlier release gets it.Scope: plain gems only. The Cargo, Go and Composer directories of #2348 are not changed here, so this is
Refs, notFixes. The gem helpers take no gem-specific input and can be shared when those backends follow.Root cause
vendor/gem.rsran the three steps (uuid metadata, emptying shipped.gitignorefiles, thegit check-ignoreprobe) only when the lock pins the gem as platform gems.redownload.rsrestored the uuid metadata under the same condition. A gem's own tree was assumed to be source files that no rule matches.Do-no-harm notes for the reviewer
repairrestores each shipped.gitignoreas the ledger inventory records it, so an old entry is restored with the gem's rules intact and still matches its inventory (restore_keeps_a_shipped_gitignore_an_earlier_release_recorded, which also passes onmain).vendor_gem_copy_gitignored(new code, documented) with the remedygit add -f <copy dir>..gitignoreis still emptied there, because existing ledger inventories record them that way.Evidence
Run locally on this branch (Ruby 3.3.6, Bundler 4.0.18, git 2.43):
cargo test -p socket-patch-core --lib vendor::cargo test -p socket-patch-cli --lib --test in_process_vendor --test e2e_vex_vendor --test vendor_revert_tamper_e2ecargo test -p socket-patch-cli --test e2e_vendor_gem_build --test e2e_redirect_gem_build --test e2e_gem_native_ext_build -- --ignoredcargo clippy --locked --workspace --all-features -- -D warnings(the CI command)cargo clippy --all-targetsreports errors in test code onmainas well (none in the lines this PR adds); CI does not run it that way.Red to green:
vendor::gem::tests::committable_gem_trees. Commit 2163464 adds five of them before the fix; four fail onmain:a_file_a_project_rule_ignores_reaches_a_fresh_clone: realgit commitandgit clone; the clone holds.rspecand the entry verifies there.a_rule_that_ignores_the_vendored_dir_refuses_the_gem: refused dry and wet, nothing written, service not asked.a_gitignore_the_gem_ships_is_emptied_in_the_copy: emptied at any depth, the template and the patched one kept, inventory healthy, re-run in sync, restore reproduces the tree.the_uuid_dir_metadata_is_put_back_by_a_rerun_and_by_restore.a_shipped_gitignore_an_earlier_release_kept_is_reported_onceandrepair_writes_the_missing_metadata_of_a_healthy_copy.e2e_vendor_gem_build::gem_vendor_file_a_project_rule_ignores_reaches_a_git_clone: diff-lcs 1.5.1 (ships.rspec) in a project withRails.gitignorelines; aftergit commitandgit clone,vendor --checkexits 0 in the clone and a frozenbundle installloads the patched gem. It fails withmain'sgem.rsandredownload.rs.Review
/code-review highran on the diff. Fixed: emptying a.gitignorethe gem uses as data; no heads-up for an old copy whose shipped.gitignorestill hides files;repairnot writing the pair for a healthy copy although the docs said so; the directory-rule check firing for an archive-wired Bazel gem; contract rows; a misplaced doc comment; the test git helper reading the machine's git config.Cursor Bugbot found one issue: a negation under an ignored directory was read as re-including the file. Fixed, with the unit test
a_shipped_gitignore_is_read_as_git_reads_it.Not fixed, with reasons:
.gitattributesthe gem ships can still change the bytes git commits (line endings). It predates this PR, applies to platform gems too, and belongs with the line-ending work of A core.autocrlf or* text=autocheckout rewrites the committed agent-mode blobs and Go patch copy: apply fails on every such clone, and for Go it removes a working patch #2318.git status.Docs
CLI_CONTRACT.md: the gem row of the vendored table,vendor_artifact_gitignored,vendor_artifact_gitignore_unchecked, and a new row forvendor_gem_copy_gitignored.docs/ecosystems.md: new section "Ruby gems: vendored gems and.gitignore".Follow-ups
https://claude.ai/code/session_011f9aeRRUb7jeJQjA9NUduE
Generated by Claude Code