nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: pre-commit/pre-commit
Pull request #1611 (2020-09-23 00:23:49)

Update pre-commit version in sample config
This is a minor change. The sample config doesn't even have the latest major version in it.

[This](https://stackoverflow.com/a/12704727) provides the solution to what is proposed in the `TODO`.
The output from
```bash
git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags git://github.com/pre-commit/pre-commit-hooks '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3
```
can be directly inserted inplace of the defined rev.

Alternatively one could borrow parts from the autoupdate command. The logic there seems to init a repository and then parses the output from git commands using functions from the util module. The above may or may not be overkill. I have not looked into the details of the different approaches yet. Seems doable though!

If that change is desired, I would be happy to update the PR accordingly.


Patch:
diff --git a/pre_commit/commands/sample_config.py b/pre_commit/commands/sample_config.py
index d435faa..64617c3 100644
--- a/pre_commit/commands/sample_config.py
+++ b/pre_commit/commands/sample_config.py
@@ -7,7 +7,7 @@ SAMPLE_CONFIG = '''\
 # See https://pre-commit.com/hooks.html for more hooks
 repos:
 -   repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v2.4.0
+    rev: v3.2.0
     hooks:
     -   id: trailing-whitespace
     -   id: end-of-file-fixer


Test patch:
diff --git a/tests/commands/sample_config_test.py b/tests/commands/sample_config_test.py
index 11c0876..8e3a904 100644
--- a/tests/commands/sample_config_test.py
+++ b/tests/commands/sample_config_test.py
@@ -10,7 +10,7 @@ def test_sample_config(capsys):
 # See https://pre-commit.com/hooks.html for more hooks
 repos:
 -   repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v2.4.0
+    rev: v3.2.0
     hooks:
     -   id: trailing-whitespace
     -   id: end-of-file-fixer
Repository: pre-commit/pre-commit
Pull request #1617 (2020-09-24 00:45:08)

don't pass through -p if using the default version
this was originally to work around a bug in old `virtualenv` -- since `virtualenv>=20` there's no more re-exec


Patch:
diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py
index afa093d..65f521c 100644
--- a/pre_commit/languages/python.py
+++ b/pre_commit/languages/python.py
@@ -132,13 +132,11 @@ def _sys_executable_matches(version: str) -> bool:
     return sys.version_info[:len(info)] == info
 
 
-def norm_version(version: str) -> str:
-    if version == C.DEFAULT:
-        return os.path.realpath(sys.executable)
-
-    # first see if our current executable is appropriate
-    if _sys_executable_matches(version):
-        return sys.executable
+def norm_version(version: str) -> Optional[str]:
+    if version == C.DEFAULT:  # use virtualenv's default
+        return None
+    elif _sys_executable_matches(version):  # virtualenv defaults to our exe
+        return None
 
     if os.name == 'nt':  # pragma: no cover (windows)
         version_exec = _find_by_py_launcher(version)
@@ -194,8 +192,10 @@ def install_environment(
         additional_dependencies: Sequence[str],
 ) -> None:
     envdir = prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version))
+    venv_cmd = [sys.executable, '-mvirtualenv', envdir]
     python = norm_version(version)
-    venv_cmd = (sys.executable, '-mvirtualenv', envdir, '-p', python)
+    if python is not None:
+        venv_cmd.extend(('-p', python))
     install_cmd = ('python', '-mpip', 'install', '.', *additional_dependencies)
 
     with clean_path_on_failure(envdir):


Test patch:
diff --git a/tests/languages/python_test.py b/tests/languages/python_test.py
index 29c5a9b..cfe1483 100644
--- a/tests/languages/python_test.py
+++ b/tests/languages/python_test.py
@@ -36,13 +36,14 @@ def test_norm_version_expanduser():
 
 
 def test_norm_version_of_default_is_sys_executable():
-    assert python.norm_version('default') == os.path.realpath(sys.executable)
+    assert python.norm_version('default') is None
 
 
 @pytest.mark.parametrize('v', ('python3.6', 'python3', 'python'))
 def test_sys_executable_matches(v):
     with mock.patch.object(sys, 'version_info', (3, 6, 7)):
         assert python._sys_executable_matches(v)
+        assert python.norm_version(v) is None
 
 
 @pytest.mark.parametrize('v', ('notpython', 'python3.x'))