Merging upstream version 2.12.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
4664708450
commit
9b2e8c29eb
10 changed files with 58 additions and 71 deletions
|
@ -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
|
||||
|
|
16
CHANGELOG.md
16
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
|
||||
===================
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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)
|
||||
|
||||
|
|
12
setup.cfg
12
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
|
||||
|
||||
|
|
26
pre_commit/make_archives.py → testing/make-archives
Normal file → Executable file
26
pre_commit/make_archives.py → testing/make-archives
Normal file → Executable file
|
@ -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
|
||||
|
|
@ -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'
|
||||
|
|
|
@ -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()
|
Loading…
Add table
Reference in a new issue