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

Skip to content

Commit 5e52a65

Browse files
committed
Remove unused ruby activate script
1 parent 5d767bb commit 5e52a65

2 files changed

Lines changed: 7 additions & 42 deletions

File tree

pre_commit/languages/ruby.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,6 @@ def _install_rbenv(
7979
_extract_resource('ruby-download.tar.gz', plugins_dir)
8080
_extract_resource('ruby-build.tar.gz', plugins_dir)
8181

82-
activate_path = prefix.path(directory, 'bin', 'activate')
83-
with open(activate_path, 'w') as activate_file:
84-
# This is similar to how you would install rbenv to your home directory
85-
# However we do a couple things to make the executables exposed and
86-
# configure it to work in our directory.
87-
# We also modify the PS1 variable for manual debugging sake.
88-
activate_file.write(
89-
'#!/usr/bin/env bash\n'
90-
"export RBENV_ROOT='{directory}'\n"
91-
'export PATH="$RBENV_ROOT/bin:$PATH"\n'
92-
'eval "$(rbenv init -)"\n'
93-
'export PS1="(rbenv)$PS1"\n'
94-
# This lets us install gems in an isolated and repeatable
95-
# directory
96-
"export GEM_HOME='{directory}/gems'\n"
97-
'export PATH="$GEM_HOME/bin:$PATH"\n'
98-
'\n'.format(directory=prefix.path(directory)),
99-
)
100-
101-
# If we aren't using the system ruby, add a version here
102-
if version != C.DEFAULT:
103-
activate_file.write(f'export RBENV_VERSION="{version}"\n')
104-
10582

10683
def _install_ruby(
10784
prefix: Prefix,

tests/languages/ruby_test.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os.path
2-
import shlex
32

4-
from pre_commit.languages.ruby import _install_rbenv
3+
from pre_commit.languages import ruby
54
from pre_commit.prefix import Prefix
65
from pre_commit.util import cmd_output
76
from testing.util import xfailif_windows_no_ruby
@@ -10,31 +9,20 @@
109
@xfailif_windows_no_ruby
1110
def test_install_rbenv(tempdir_factory):
1211
prefix = Prefix(tempdir_factory.get())
13-
_install_rbenv(prefix)
12+
ruby._install_rbenv(prefix)
1413
# Should have created rbenv directory
1514
assert os.path.exists(prefix.path('rbenv-default'))
16-
# We should have created our `activate` script
17-
activate_path = prefix.path('rbenv-default', 'bin', 'activate')
18-
assert os.path.exists(activate_path)
1915

2016
# Should be able to activate using our script and access rbenv
21-
cmd_output(
22-
'bash', '-c',
23-
'. {} && rbenv --help'.format(
24-
shlex.quote(prefix.path('rbenv-default', 'bin', 'activate')),
25-
),
26-
)
17+
with ruby.in_env(prefix, 'default'):
18+
cmd_output('rbenv', '--help')
2719

2820

2921
@xfailif_windows_no_ruby
3022
def test_install_rbenv_with_version(tempdir_factory):
3123
prefix = Prefix(tempdir_factory.get())
32-
_install_rbenv(prefix, version='1.9.3p547')
24+
ruby._install_rbenv(prefix, version='1.9.3p547')
3325

3426
# Should be able to activate and use rbenv install
35-
cmd_output(
36-
'bash', '-c',
37-
'. {} && rbenv install --help'.format(
38-
shlex.quote(prefix.path('rbenv-1.9.3p547', 'bin', 'activate')),
39-
),
40-
)
27+
with ruby.in_env(prefix, '1.9.3p547'):
28+
cmd_output('rbenv', 'install', '--help')

0 commit comments

Comments
 (0)