Skip to content

Prevent tests from modifying user's global git config#9397

Open
hsbt wants to merge 2 commits intomasterfrom
prevent-git-config
Open

Prevent tests from modifying user's global git config#9397
hsbt wants to merge 2 commits intomasterfrom
prevent-git-config

Conversation

@hsbt
Copy link
Member

@hsbt hsbt commented Mar 16, 2026

Set GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM environment 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 to filters.rb using existing RequirementChecker, so that specs tagged with git: ">= 2.28.0" etc. are properly skipped on older Git versions

Make sure the following tasks are checked

hsbt and others added 2 commits March 16, 2026 12:35
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>
Copilot AI review requested due to automatic review settings March 16, 2026 04:56
Copy link
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

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 in bundler/spec/support/filters.rb using RequirementChecker and 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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants