From bee56cd5bc619540a93f05aa60033a1d2009f8ed Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 23 Jun 2014 13:50:40 -0700 Subject: [PATCH] Use our archives instead of pulling from gits. --- pre_commit/languages/ruby.py | 20 +++++++++----------- tests/languages/ruby_test.py | 5 ----- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/pre_commit/languages/ruby.py b/pre_commit/languages/ruby.py index b4a3be06..2f4b9931 100644 --- a/pre_commit/languages/ruby.py +++ b/pre_commit/languages/ruby.py @@ -6,6 +6,8 @@ import io from pre_commit.languages import helpers from pre_commit.prefixed_command_runner import CalledProcessError from pre_commit.util import clean_path_on_failure +from pre_commit.util import resource_filename +from pre_commit.util import tarfile_open ENVIRONMENT_DIR = 'rbenv' @@ -23,22 +25,18 @@ def in_env(repo_cmd_runner): def _install_rbenv(repo_cmd_runner, version='default'): - repo_cmd_runner.run([ - 'git', 'clone', 'git://github.com/sstephenson/rbenv', '{prefix}rbenv', - ]) + with tarfile_open(resource_filename('rbenv.tar.gz')) as tf: + tf.extractall(repo_cmd_runner.path('.')) # Only install ruby-build if the version is specified if version != 'default': # ruby-download - repo_cmd_runner.run([ - 'git', 'clone', 'git://github.com/garnieretienne/rvm-download', - '{prefix}rbenv/plugins/ruby-download', - ]) + with tarfile_open(resource_filename('ruby-download.tar.gz')) as tf: + tf.extractall(repo_cmd_runner.path('rbenv', 'plugins')) + # ruby-build - repo_cmd_runner.run([ - 'git', 'clone', 'git://github.com/sstephenson/ruby-build', - '{prefix}rbenv/plugins/ruby-build', - ]) + with tarfile_open(resource_filename('ruby-build.tar.gz')) as tf: + tf.extractall(repo_cmd_runner.path('rbenv', 'plugins')) activate_path = repo_cmd_runner.path('rbenv', 'bin', 'activate') with io.open(activate_path, 'w') as activate_file: diff --git a/tests/languages/ruby_test.py b/tests/languages/ruby_test.py index d55b36b0..3ffb4019 100644 --- a/tests/languages/ruby_test.py +++ b/tests/languages/ruby_test.py @@ -3,16 +3,12 @@ from __future__ import unicode_literals import os.path from pre_commit.languages.ruby import _install_rbenv -from testing.util import skipif_slowtests_false -@skipif_slowtests_false def test_install_rbenv(cmd_runner): _install_rbenv(cmd_runner) # Should have created rbenv directory assert os.path.exists(cmd_runner.path('rbenv')) - # It should be a git checkout - assert os.path.exists(cmd_runner.path('rbenv', '.git')) # We should have created our `activate` script activate_path = cmd_runner.path('rbenv', 'bin', 'activate') assert os.path.exists(activate_path) @@ -27,7 +23,6 @@ def test_install_rbenv(cmd_runner): ) -@skipif_slowtests_false def test_install_rbenv_with_version(cmd_runner): _install_rbenv(cmd_runner, version='1.9.3p547')