1
0
Fork 0

Adding upstream version 3.6.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 21:46:36 +01:00
parent 0e9e0db1eb
commit eff035fa99
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
6 changed files with 36 additions and 3 deletions

View file

@ -33,11 +33,11 @@ repos:
hooks:
- id: autopep8
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [types-all]

View file

@ -1,3 +1,13 @@
3.6.1 - 2024-02-10
==================
### Fixes
- Remove `PYTHONEXECUTABLE` from environment when running.
- #3110 PR by @untitaker.
- Handle staged-files-only with only a crlf diff.
- #3126 PR by @asottile.
- issue by @tyyrok.
3.6.0 - 2023-12-09
==================

View file

@ -37,6 +37,9 @@ logger = logging.getLogger('pre_commit')
# pyvenv
os.environ.pop('__PYVENV_LAUNCHER__', None)
# https://github.com/getsentry/snuba/pull/5388
os.environ.pop('PYTHONEXECUTABLE', None)
COMMANDS_NO_GIT = {
'clean', 'gc', 'init-templatedir', 'sample-config',
'validate-config', 'validate-manifest',

View file

@ -59,6 +59,11 @@ def _unstaged_changes_cleared(patch_dir: str) -> Generator[None, None, None]:
# There weren't any staged files so we don't need to do anything
# special
yield
elif retcode == 1 and not diff_stdout.strip():
# due to behaviour (probably a bug?) in git with crlf endings and
# autocrlf set to either `true` or `input` sometimes git will refuse
# to show a crlf-only diff to us :(
yield
elif retcode == 1 and diff_stdout.strip():
patch_filename = f'patch{int(time.time())}-{os.getpid()}'
patch_filename = os.path.join(patch_dir, patch_filename)

View file

@ -1,6 +1,6 @@
[metadata]
name = pre_commit
version = 3.6.0
version = 3.6.1
description = A framework for managing and maintaining multi-language pre-commit hooks.
long_description = file: README.md
long_description_content_type = text/markdown

View file

@ -358,6 +358,21 @@ def test_crlf(in_git_dir, patch_dir, crlf_before, crlf_after, autocrlf):
assert_no_diff()
@pytest.mark.parametrize('autocrlf', ('true', 'input'))
def test_crlf_diff_only(in_git_dir, patch_dir, autocrlf):
# due to a quirk (?) in git -- a diff only in crlf does not show but
# still results in an exit code of `1`
# we treat this as "no diff" -- though ideally it would discard the diff
# while committing
cmd_output('git', 'config', '--local', 'core.autocrlf', autocrlf)
_write(b'1\r\n2\r\n3\r\n')
cmd_output('git', 'add', 'foo')
_write(b'1\n2\n3\n')
with staged_files_only(patch_dir):
pass
def test_whitespace_errors(in_git_dir, patch_dir):
cmd_output('git', 'config', '--local', 'apply.whitespace', 'error')
test_crlf(in_git_dir, patch_dir, True, True, 'true')