summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-04-10 14:27:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-04-19 13:32:50 +0000
commit35f0c72f09eaa652cb468ed1b4ad7c707ed83c5e (patch)
treec0257364c514cb1c845d82e34a6e5dd9b1fc28c3 /testing
parentReleasing debian version 2.11.1-1. (diff)
downloadpre-commit-35f0c72f09eaa652cb468ed1b4ad7c707ed83c5e.tar.xz
pre-commit-35f0c72f09eaa652cb468ed1b4ad7c707ed83c5e.zip
Merging upstream version 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