Skip to content

Commit e431b2b

Browse files
authored
Merge pull request #1854 from pre-commit/upgrade_ruby_build
upgrade ruby-build
2 parents 060b719 + 3bada74 commit e431b2b

File tree

3 files changed

+11
-58
lines changed

3 files changed

+11
-58
lines changed
1.32 KB
Binary file not shown.
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1+
#!/usr/bin/env python3
12
import argparse
23
import os.path
4+
import shutil
5+
import subprocess
36
import tarfile
7+
import tempfile
48
from typing import Optional
59
from typing import Sequence
610

7-
from pre_commit import output
8-
from pre_commit.util import cmd_output_b
9-
from pre_commit.util import rmtree
10-
from pre_commit.util import tmpdir
11-
1211

1312
# This is a script for generating the tarred resources for git repo
1413
# dependencies. Currently it's just for "vendoring" ruby support packages.
1514

1615

1716
REPOS = (
1817
('rbenv', 'git://github.com/rbenv/rbenv', '0843745'),
19-
('ruby-build', 'git://github.com/rbenv/ruby-build', '258455e'),
18+
('ruby-build', 'git://github.com/rbenv/ruby-build', '500863c'),
2019
(
2120
'ruby-download',
2221
'git://github.com/garnieretienne/rvm-download',
@@ -35,18 +34,18 @@ def make_archive(name: str, repo: str, ref: str, destdir: str) -> str:
3534
:param text destdir: Directory to place archives in.
3635
"""
3736
output_path = os.path.join(destdir, f'{name}.tar.gz')
38-
with tmpdir() as tempdir:
37+
with tempfile.TemporaryDirectory() as tmpdir:
3938
# Clone the repository to the temporary directory
40-
cmd_output_b('git', 'clone', repo, tempdir)
41-
cmd_output_b('git', 'checkout', ref, cwd=tempdir)
39+
subprocess.check_call(('git', 'clone', repo, tmpdir))
40+
subprocess.check_call(('git', '-C', tmpdir, 'checkout', ref))
4241

4342
# We don't want the '.git' directory
4443
# It adds a bunch of size to the archive and we don't use it at
4544
# runtime
46-
rmtree(os.path.join(tempdir, '.git'))
45+
shutil.rmtree(os.path.join(tmpdir, '.git'))
4746

4847
with tarfile.open(output_path, 'w|gz') as tf:
49-
tf.add(tempdir, name)
48+
tf.add(tmpdir, name)
5049

5150
return output_path
5251

@@ -56,7 +55,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
5655
parser.add_argument('--dest', default='pre_commit/resources')
5756
args = parser.parse_args(argv)
5857
for archive_name, repo, ref in REPOS:
59-
output.write_line(f'Making {archive_name}.tar.gz for {repo}@{ref}')
58+
print(f'Making {archive_name}.tar.gz for {repo}@{ref}')
6059
make_archive(archive_name, repo, ref, args.dest)
6160
return 0
6261

tests/make_archives_test.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)