Merge pull request #215429 from aaronjheng/pre-commit

pre-commit: 2.20.0 -> 3.1.0
This commit is contained in:
Sandro 2023-03-09 16:26:57 +01:00 committed by GitHub
commit 22fe81ef86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 64 deletions

View File

@ -1,28 +1,32 @@
{ lib { lib
, python3Packages
, fetchFromGitHub , fetchFromGitHub
# tests , python3Packages
, libiconv
, cargo , cargo
, coursier
, dotnet-sdk , dotnet-sdk
, git , git
, glibcLocales
, go , go
, libiconv
, nodejs , nodejs
, perl
, testers
, pre-commit
}: }:
with python3Packages; with python3Packages;
buildPythonPackage rec { buildPythonApplication rec {
pname = "pre-commit"; pname = "pre-commit";
version = "2.20.0"; version = "3.1.0";
format = "setuptools"; format = "setuptools";
disabled = pythonOlder "3.6"; disabled = pythonOlder "3.8";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "pre-commit"; owner = "pre-commit";
repo = "pre-commit"; repo = "pre-commit";
rev = "refs/tags/v${version}"; rev = "v${version}";
sha256 = "sha256-+JrnJz+wFbzVw9ysPX85DDE6suF3VU7gQZdp66x5TKY="; hash = "sha256-riAXvpJmuQHOfruwebijiAgN2AvqpUUI07p758qO+4k=";
}; };
patches = [ patches = [
@ -37,18 +41,18 @@ buildPythonPackage rec {
pyyaml pyyaml
toml toml
virtualenv virtualenv
] ++ lib.optionals (pythonOlder "3.8") [
importlib-metadata
] ++ lib.optionals (pythonOlder "3.7") [
importlib-resources
]; ];
nativeCheckInputs = [ nativeCheckInputs = [
cargo cargo
coursier
dotnet-sdk dotnet-sdk
git git
glibcLocales
go go
libiconv # For rust tests on Darwin
nodejs nodejs
perl
pytest-env pytest-env
pytest-forked pytest-forked
pytest-xdist pytest-xdist
@ -56,11 +60,6 @@ buildPythonPackage rec {
re-assert re-assert
]; ];
buildInputs = [
# Required for rust test on x86_64-darwin
libiconv
];
# i686-linux: dotnet-sdk not available # i686-linux: dotnet-sdk not available
doCheck = stdenv.buildPlatform.system != "i686-linux"; doCheck = stdenv.buildPlatform.system != "i686-linux";
@ -79,19 +78,23 @@ buildPythonPackage rec {
"--forked" "--forked"
]; ];
preCheck = '' preCheck = lib.optionalString (!(stdenv.isLinux && stdenv.isAarch64)) ''
# Disable outline atomics for rust tests on aarch64-linux.
export RUSTFLAGS="-Ctarget-feature=-outline-atomics"
'' + ''
export GIT_AUTHOR_NAME=test GIT_COMMITTER_NAME=test \ export GIT_AUTHOR_NAME=test GIT_COMMITTER_NAME=test \
GIT_AUTHOR_EMAIL=test@example.com GIT_COMMITTER_EMAIL=test@example.com \ GIT_AUTHOR_EMAIL=test@example.com GIT_COMMITTER_EMAIL=test@example.com \
VIRTUALENV_NO_DOWNLOAD=1 PRE_COMMIT_NO_CONCURRENCY=1 LANG=en_US.UTF-8 VIRTUALENV_NO_DOWNLOAD=1 PRE_COMMIT_NO_CONCURRENCY=1 LANG=en_US.UTF-8
git init -b master # Resolve `.NET location: Not found` errors for dotnet tests
export DOTNET_ROOT="${dotnet-sdk}"
export HOME=$(mktemp -d) export HOME=$(mktemp -d)
git init -b master
python -m venv --system-site-packages venv python -m venv --system-site-packages venv
source "$PWD/venv/bin/activate" source "$PWD/venv/bin/activate"
#$out/bin/pre-commit install
python setup.py develop
''; '';
postCheck = '' postCheck = ''
@ -106,7 +109,7 @@ buildPythonPackage rec {
# /build/pytest-of-nixbld/pytest-0/test_install_ruby_with_version0/rbenv-2.7.2/libexec/rbenv-init: # /build/pytest-of-nixbld/pytest-0/test_install_ruby_with_version0/rbenv-2.7.2/libexec/rbenv-init:
# /usr/bin/env: bad interpreter: No such file or directory # /usr/bin/env: bad interpreter: No such file or directory
"ruby" "test_ruby_"
# network # network
"test_additional_dependencies_roll_forward" "test_additional_dependencies_roll_forward"
@ -114,60 +117,59 @@ buildPythonPackage rec {
"test_additional_node_dependencies_installed" "test_additional_node_dependencies_installed"
"test_additional_rust_cli_dependencies_installed" "test_additional_rust_cli_dependencies_installed"
"test_additional_rust_lib_dependencies_installed" "test_additional_rust_lib_dependencies_installed"
"test_dart_hook" "test_coursier_hook"
"test_dotnet_hook" "test_coursier_hook_additional_dependencies"
"test_dart"
"test_dart_additional_deps"
"test_dart_additional_deps_versioned"
"test_docker_hook"
"test_docker_image_hook_via_args"
"test_docker_image_hook_via_entrypoint"
"test_golang_default_version"
"test_golang_hook" "test_golang_hook"
"test_golang_hook_still_works_when_gobin_is_set" "test_golang_hook_still_works_when_gobin_is_set"
"test_golang_infer_go_version_default"
"test_golang_system"
"test_golang_versioned"
"test_language_version_with_rustup"
"test_installs_rust_missing_rustup"
"test_installs_without_links_outside_env" "test_installs_without_links_outside_env"
"test_local_dart_additional_dependencies" "test_local_golang_additional_deps"
"test_local_golang_additional_dependencies" "test_lua"
"test_local_lua_additional_dependencies" "test_lua_additional_dependencies"
"test_local_perl_additional_dependencies" "test_node_additional_deps"
"test_local_rust_additional_dependencies" "test_node_hook_versions"
"test_lua_hook" "test_perl_additional_dependencies"
"test_perl_hook"
"test_r_hook" "test_r_hook"
"test_r_inline"
"test_r_inline_hook" "test_r_inline_hook"
"test_r_local_with_additional_dependencies_hook" "test_r_local_with_additional_dependencies_hook"
"test_r_with_additional_dependencies_hook" "test_r_with_additional_dependencies_hook"
"test_run_a_node_hook_default_version" "test_run_a_node_hook_default_version"
"test_run_lib_additional_dependencies"
"test_run_versioned_node_hook" "test_run_versioned_node_hook"
"test_rust_cli_additional_dependencies"
# python2, no explanation needed "test_swift_language"
"python2"
"test_switch_language_versions_doesnt_clobber"
# docker
"test_run_a_docker_hook"
# i don't know why these fail # i don't know why these fail
"test_install_existing_hooks_no_overwrite" "test_install_existing_hooks_no_overwrite"
"test_installed_from_venv" "test_installed_from_venv"
"test_uninstall_restores_legacy_hooks" "test_uninstall_restores_legacy_hooks"
"test_dotnet_"
# Expects `git commit` to fail when `pre-commit` is not in the `$PATH`, # Expects `git commit` to fail when `pre-commit` is not in the `$PATH`,
# but we use an absolute path so it's not an issue. # but we use an absolute path so it's not an issue.
"test_environment_not_sourced" "test_environment_not_sourced"
# broken with Git 2.38.1, upstream issue filed at https://github.com/pre-commit/pre-commit/issues/2579
"test_golang_with_recursive_submodule"
"test_install_in_submodule_and_run"
"test_is_in_merge_conflict_submodule"
"test_get_conflicted_files_in_submodule"
"test_sub_nothing_unstaged"
"test_sub_something_unstaged"
"test_sub_staged"
"test_submodule_does_not_discard_changes"
"test_submodule_does_not_discard_changes_recurse"
] ++ lib.optionals (stdenv.isLinux && stdenv.isAarch64) [
# requires gcc bump
"test_rust_hook"
]; ];
pythonImportsCheck = [ pythonImportsCheck = [
"pre_commit" "pre_commit"
]; ];
passthru.tests.version = testers.testVersion {
package = pre-commit;
};
meta = with lib; { meta = with lib; {
description = "A framework for managing and maintaining multi-language pre-commit hooks"; description = "A framework for managing and maintaining multi-language pre-commit hooks";
homepage = "https://pre-commit.com/"; homepage = "https://pre-commit.com/";

View File

@ -1,24 +1,24 @@
diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py
index 26f4919..4885ec1 100644 index 66d6136..e3f1bac 100644
--- a/pre_commit/languages/node.py --- a/pre_commit/languages/node.py
+++ b/pre_commit/languages/node.py +++ b/pre_commit/languages/node.py
@@ -82,7 +82,7 @@ def install_environment( @@ -83,7 +83,7 @@ def install_environment(
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx?f=255&MSPPError=-2147217396#maxpath
if sys.platform == 'win32': # pragma: no cover
envdir = fr'\\?\{os.path.normpath(envdir)}' envdir = fr'\\?\{os.path.normpath(envdir)}'
with clean_path_on_failure(envdir): - cmd = [sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir]
cmd = [ + cmd = ['@nodeenv@/bin/nodeenv', '--prebuilt', '--clean-src', envdir]
- sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir, if version != C.DEFAULT:
+ '@nodeenv@/bin/nodeenv', '--prebuilt', '--clean-src', envdir, cmd.extend(['-n', version])
] cmd_output_b(*cmd)
if version != C.DEFAULT:
cmd.extend(['-n', version])
diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py
index 43b7280..f0f2338 100644 index 976674e..485fe2d 100644
--- a/pre_commit/languages/python.py --- a/pre_commit/languages/python.py
+++ b/pre_commit/languages/python.py +++ b/pre_commit/languages/python.py
@@ -192,7 +192,7 @@ def install_environment( @@ -203,7 +203,7 @@ def install_environment(
additional_dependencies: Sequence[str], additional_dependencies: Sequence[str],
) -> None: ) -> None:
envdir = prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version)) envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)
- venv_cmd = [sys.executable, '-mvirtualenv', envdir] - venv_cmd = [sys.executable, '-mvirtualenv', envdir]
+ venv_cmd = ['@virtualenv@/bin/virtualenv', envdir] + venv_cmd = ['@virtualenv@/bin/virtualenv', envdir]
python = norm_version(version) python = norm_version(version)