diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-04-10 14:27:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-04-10 14:27:51 +0000 |
commit | 629f6511c5a49f56689ba18053d8cf8ff91a8829 (patch) | |
tree | 4393e565bfa4ba3117ac3ed74fabacd54e3366db /testing/make-archives | |
parent | Adding upstream version 2.11.1. (diff) | |
download | pre-commit-629f6511c5a49f56689ba18053d8cf8ff91a8829.tar.xz pre-commit-629f6511c5a49f56689ba18053d8cf8ff91a8829.zip |
Adding upstream version 2.12.0.upstream/2.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--] | testing/make-archives (renamed from pre_commit/make_archives.py) | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/pre_commit/make_archives.py b/testing/make-archives index d320b83..b2b288c 100644..100755 --- a/pre_commit/make_archives.py +++ b/testing/make-archives @@ -1,14 +1,13 @@ +#!/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. @@ -16,7 +15,7 @@ from pre_commit.util import tmpdir 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', @@ -35,18 +34,21 @@ 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: + # this ensures that the root directory has umask permissions + gitdir = os.path.join(tmpdir, 'root') + # 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, gitdir)) + subprocess.check_call(('git', '-C', gitdir, '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(gitdir, '.git')) with tarfile.open(output_path, 'w|gz') as tf: - tf.add(tempdir, name) + tf.add(gitdir, name) return output_path @@ -56,7 +58,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 |