Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade ruby-build #1854

Merged
merged 1 commit into from Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified pre_commit/resources/ruby-build.tar.gz
Binary file not shown.
23 changes: 11 additions & 12 deletions pre_commit/make_archives.py → testing/make-archives 100644 → 100755
@@ -1,22 +1,21 @@
#!/usr/bin/env python3
import argparse
import os.path
import shutil
import subprocess
import tarfile
import tempfile
from typing import Optional
from typing import Sequence

from pre_commit import output
from pre_commit.util import cmd_output_b
from pre_commit.util import rmtree
from pre_commit.util import tmpdir


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


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

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

with tarfile.open(output_path, 'w|gz') as tf:
tf.add(tempdir, name)
tf.add(tmpdir, name)

return output_path

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

Expand Down
46 changes: 0 additions & 46 deletions tests/make_archives_test.py

This file was deleted.