Prevent tests from modifying user's global git config#9397
Open
Prevent tests from modifying user's global git config#9397
Conversation
Set GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM environment variables in the test suite setup to isolate git configuration when Git >= 2.32 is available. This prevents test runs from accidentally polluting the developer's real git config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use RequirementChecker to filter specs tagged with git version requirements (e.g., `git: ">= 2.28.0"`), matching the existing pattern used for rubygems version filtering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Bundler’s spec harness to better isolate Git behavior during test runs and to support skipping specs based on the installed Git version.
Changes:
- Add a
git:metadata filter inbundler/spec/support/filters.rbusingRequirementCheckerand the detected Git version. - In spec suite setup, set Git-related environment variables intended to prevent tests from writing to real user/system Git config.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| bundler/spec/support/filters.rb | Detects Git version and introduces git: version-based spec filtering. |
| bundler/spec/spec_helper.rb | Sets GIT_CONFIG_GLOBAL / GIT_CONFIG_NOSYSTEM during suite setup to isolate Git config writes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+21
to
+22
| git_version = Gem::Version.new(`git --version`[/(\d+\.\d+\.\d+)/, 1]) | ||
|
|
Comment on lines
+133
to
+134
| git_version = `git --version`[/(\d+\.\d+\.\d+)/, 1] | ||
| if Gem::Version.new(git_version) >= Gem::Version.new("2.32") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Set
GIT_CONFIG_GLOBALandGIT_CONFIG_NOSYSTEMenvironment variables in the test suite setup to isolate git configuration, preventing test runs from polluting the developer's global git config (e.g., commits authored as lolwut)And I added
git:version filter tofilters.rbusing existingRequirementChecker, so that specs tagged withgit: ">= 2.28.0"etc. are properly skipped on older Git versionsMake sure the following tasks are checked