summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--.pre-commit-config.yaml12
-rw-r--r--CHANGELOG.md16
-rw-r--r--pre_commit/resources/rbenv.tar.gzbin34224 -> 34250 bytes
-rw-r--r--pre_commit/resources/ruby-build.tar.gzbin72807 -> 74218 bytes
-rw-r--r--pre_commit/resources/ruby-download.tar.gzbin5343 -> 5533 bytes
-rw-r--r--pre_commit/xargs.py4
-rw-r--r--setup.cfg12
-rwxr-xr-x[-rw-r--r--]testing/make-archives (renamed from pre_commit/make_archives.py)26
-rw-r--r--tests/languages/ruby_test.py13
-rw-r--r--tests/make_archives_test.py46
10 files changed, 58 insertions, 71 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index bcfde90..0c6d636 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -11,21 +11,21 @@ repos:
- id: name-tests-test
- id: requirements-txt-fixer
- id: double-quote-string-fixer
-- repo: https://gitlab.com/pycqa/flake8
- rev: 3.8.4
+- repo: https://github.com/PyCQA/flake8
+ rev: 3.9.0
hooks:
- id: flake8
additional_dependencies: [flake8-typing-imports==1.10.0]
- repo: https://github.com/pre-commit/mirrors-autopep8
- rev: v1.5.4
+ rev: v1.5.6
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/pre-commit
- rev: v2.11.1
+ rev: v2.12.0
hooks:
- id: validate_manifest
- repo: https://github.com/asottile/pyupgrade
- rev: v2.10.0
+ rev: v2.11.0
hooks:
- id: pyupgrade
args: [--py36-plus]
@@ -40,7 +40,7 @@ repos:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
- rev: v1.16.0
+ rev: v1.17.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/pre-commit/mirrors-mypy
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5da7866..2d6a35d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,19 @@
+2.12.0 - 2021-04-06
+===================
+
+### Features
+- Upgrade rbenv.
+ - #1854 PR by @asottile.
+ - #1848 issue by @sirosen.
+
+### Fixes
+- Give command length a little more room when running batch files on windows
+ so underlying commands can expand further.
+ - #1864 PR by @asottile.
+ - pre-commit/mirrors-prettier#7 issue by @DeltaXWizard.
+- Fix permissions of root folder in ruby archives.
+ - #1868 PR by @asottile.
+
2.11.1 - 2021-03-09
===================
diff --git a/pre_commit/resources/rbenv.tar.gz b/pre_commit/resources/rbenv.tar.gz
index 97ac469..95b5a36 100644
--- a/pre_commit/resources/rbenv.tar.gz
+++ b/pre_commit/resources/rbenv.tar.gz
Binary files differ
diff --git a/pre_commit/resources/ruby-build.tar.gz b/pre_commit/resources/ruby-build.tar.gz
index 4412ed4..ef82e2f 100644
--- a/pre_commit/resources/ruby-build.tar.gz
+++ b/pre_commit/resources/ruby-build.tar.gz
Binary files differ
diff --git a/pre_commit/resources/ruby-download.tar.gz b/pre_commit/resources/ruby-download.tar.gz
index 7ccfb6c..2e19507 100644
--- a/pre_commit/resources/ruby-download.tar.gz
+++ b/pre_commit/resources/ruby-download.tar.gz
Binary files differ
diff --git a/pre_commit/xargs.py b/pre_commit/xargs.py
index 60a057c..6b0fa20 100644
--- a/pre_commit/xargs.py
+++ b/pre_commit/xargs.py
@@ -145,7 +145,9 @@ def xargs(
# this is implementation details but the command gets translated into
# full/path/to/cmd.exe /c *cmd
cmd_exe = parse_shebang.find_executable('cmd.exe')
- _max_length = 8192 - len(cmd_exe) - len(' /c ')
+ # 1024 is additionally subtracted to give headroom for further
+ # expansion inside the batch file
+ _max_length = 8192 - len(cmd_exe) - len(' /c ') - 1024
partitions = partition(cmd, varargs, target_concurrency, _max_length)
diff --git a/setup.cfg b/setup.cfg
index a14e95d..b336e58 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = pre_commit
-version = 2.11.1
+version = 2.12.0
description = A framework for managing and maintaining multi-language pre-commit hooks.
long_description = file: README.md
long_description_content_type = text/markdown
@@ -33,6 +33,11 @@ install_requires =
importlib-resources;python_version<"3.7"
python_requires = >=3.6.1
+[options.packages.find]
+exclude =
+ tests*
+ testing*
+
[options.entry_points]
console_scripts =
pre-commit = pre_commit.main:main
@@ -45,11 +50,6 @@ pre_commit.resources =
empty_template_*
hook-tmpl
-[options.packages.find]
-exclude =
- tests*
- testing*
-
[bdist_wheel]
universal = True
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
diff --git a/tests/languages/ruby_test.py b/tests/languages/ruby_test.py
index 6c0c9e5..0c6cfed 100644
--- a/tests/languages/ruby_test.py
+++ b/tests/languages/ruby_test.py
@@ -1,4 +1,5 @@
import os.path
+import tarfile
from unittest import mock
import pytest
@@ -8,6 +9,7 @@ from pre_commit import parse_shebang
from pre_commit.languages import ruby
from pre_commit.prefix import Prefix
from pre_commit.util import cmd_output
+from pre_commit.util import resource_bytesio
from testing.util import xfailif_windows
@@ -72,3 +74,14 @@ def test_install_ruby_with_version(fake_gem_prefix):
# Should be able to activate and use rbenv install
with ruby.in_env(fake_gem_prefix, '2.7.2'):
cmd_output('rbenv', 'install', '--help')
+
+
+@pytest.mark.parametrize(
+ 'filename',
+ ('rbenv.tar.gz', 'ruby-build.tar.gz', 'ruby-download.tar.gz'),
+)
+def test_archive_root_stat(filename):
+ with resource_bytesio(filename) as f:
+ with tarfile.open(fileobj=f) as tarf:
+ root, _, _ = filename.partition('.')
+ assert oct(tarf.getmember(root).mode) == '0o755'
diff --git a/tests/make_archives_test.py b/tests/make_archives_test.py
deleted file mode 100644
index 6ae2f8e..0000000
--- a/tests/make_archives_test.py
+++ /dev/null
@@ -1,46 +0,0 @@
-import tarfile
-
-from pre_commit import git
-from pre_commit import make_archives
-from pre_commit.util import cmd_output
-from testing.util import git_commit
-
-
-def test_make_archive(in_git_dir, tmpdir):
- output_dir = tmpdir.join('output').ensure_dir()
- # Add a files to the git directory
- in_git_dir.join('foo').ensure()
- cmd_output('git', 'add', '.')
- git_commit()
- # We'll use this rev
- head_rev = git.head_rev('.')
- # And check that this file doesn't exist
- in_git_dir.join('bar').ensure()
- cmd_output('git', 'add', '.')
- git_commit()
-
- # Do the thing
- archive_path = make_archives.make_archive(
- 'foo', in_git_dir.strpath, head_rev, output_dir.strpath,
- )
-
- expected = output_dir.join('foo.tar.gz')
- assert archive_path == expected.strpath
- assert expected.exists()
-
- extract_dir = tmpdir.join('extract').ensure_dir()
- with tarfile.open(archive_path) as tf:
- tf.extractall(extract_dir.strpath)
-
- # Verify the contents of the tar
- assert extract_dir.join('foo').isdir()
- assert extract_dir.join('foo/foo').exists()
- assert not extract_dir.join('foo/.git').exists()
- assert not extract_dir.join('foo/bar').exists()
-
-
-def test_main(tmpdir):
- make_archives.main(('--dest', tmpdir.strpath))
-
- for archive, _, _ in make_archives.REPOS:
- assert tmpdir.join(f'{archive}.tar.gz').exists()