Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2093395

Browse files
authored
Merge pull request #472 from chriskuehl/gemfile-in-root
Fix ruby hooks in projects with weird options in.bundle/config
2 parents ad8eb93 + 8f057b0 commit 2093395

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

pre_commit/languages/ruby.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def get_env_patch(venv, language_version): # pragma: windows no cover
2222
patches = (
2323
('GEM_HOME', os.path.join(venv, 'gems')),
2424
('RBENV_ROOT', venv),
25+
('BUNDLE_IGNORE_CONFIG', '1'),
2526
('PATH', (
2627
os.path.join(venv, 'gems', 'bin'), os.pathsep,
2728
os.path.join(venv, 'shims'), os.pathsep,

tests/repository_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,30 @@ def test_run_versioned_ruby_hook(tempdir_factory, store):
207207
)
208208

209209

210+
@skipif_slowtests_false
211+
@xfailif_windows_no_ruby
212+
@pytest.mark.integration
213+
def test_run_ruby_hook_with_disable_shared_gems(
214+
tempdir_factory,
215+
store,
216+
tmpdir,
217+
):
218+
"""Make sure a Gemfile in the project doesn't interfere."""
219+
tmpdir.join('Gemfile').write('gem "lol_hai"')
220+
tmpdir.join('.bundle').mkdir()
221+
tmpdir.join('.bundle', 'config').write(
222+
'BUNDLE_DISABLE_SHARED_GEMS: true\n'
223+
'BUNDLE_PATH: vendor/gem\n'
224+
)
225+
with cwd(tmpdir.strpath):
226+
_test_hook_repo(
227+
tempdir_factory, store, 'ruby_versioned_hooks_repo',
228+
'ruby_hook',
229+
['/dev/null'],
230+
b'2.1.5\nHello world from a ruby hook\n',
231+
)
232+
233+
210234
@pytest.mark.integration
211235
def test_system_hook_with_spaces(tempdir_factory, store):
212236
_test_hook_repo(

0 commit comments

Comments
 (0)