Commit Graph

265 Commits

Author SHA1 Message Date
Matt Whitaker
702ebf402c Expose prepare-commit-msg arguments as environment vars 2022-06-11 14:25:55 -04:00
Anthony Sottile
777ffdd692 deprecate pre-commit-validate-{config,manifest} 2022-04-24 19:08:47 -04:00
Wade Carpenter
feb0d34213 pre-push: fix stdin line splitting when <local ref> has whitespace
From the `pre-push.sample` file:

> Information about the commits which are being pushed is supplied as
> lines to the standard input in the form:
>
>   <local ref> <local sha1> <remote ref> <remote sha1>

When `<local ref>` is not simply a branch name, but a more general
ref (see git-rev-parse(1)), it could contain whitespace, and that
breaks the split() call that expected only 3 spaces in the line.

Changed to use `rsplit(maxsplit=3)` since only the <local ref> is
likely to have embedded whitespace.

Added a new test case for the same.
2022-04-14 14:27:46 -07:00
Anthony Sottile
7602abc3cf Merge pull request #2322 from pre-commit/default-install-hook-types
implement default_install_hook_types
2022-04-02 15:36:59 -04:00
Anthony Sottile
fd0177ae3a implement default_install_hook_types
this implements a configurable fallback for the default value of `pre-commit install`
2022-04-02 15:11:31 -04:00
Daniel Schürmann
ba132f0200 Split get_git_dir() into get_git_dir() and get_git_common_dir()
This fixes the conflicted state check when using work trees. #1972
2022-04-02 15:07:22 -04:00
Matt Layman
e8b46c1b16 Pick a tag if multiple tags exist on a SHA.
Fixes #2311
2022-03-31 10:37:51 -04:00
Anthony Sottile
04de6a2e57 drop python 3.6 support
python 3.6 reached end of life on 2021-12-23
2022-01-18 18:44:20 -05:00
Anthony Sottile
e3dc3f7934 always use #!/bin/sh on windows 2022-01-05 13:22:49 -05:00
Anthony Sottile
42b0a263a6 run dead, remove dead code
via https://github.com/asottile/dead
2021-12-22 11:30:55 -08:00
Stojan Nedic
63ae399db0 Add fail_fast support per-hook 2021-10-22 19:16:30 -04:00
Anthony Sottile
e622f793c3 port hook template to bash
this avoids some version-specific code in python

this also makes the bootstrap script slightly more portable
2021-09-27 19:34:04 -04:00
Anthony Sottile
ab94dd69f8 fix pre-commit autoupdate for core.useBuiltinFSMonitor=true on windows 2021-09-13 20:01:25 -04:00
Jordan Speicher
4cd8b364dd Add: post-rewrite hook support 2021-09-01 14:50:59 -05:00
Anthony Sottile
726f2ad0a3 remove duplicate warnings while running autoupdate 2021-08-30 20:56:24 -04:00
Florent Clarret
584fd585ec Expose local branch ref as an environment variable 2021-06-19 18:18:14 +02:00
Anthony Sottile
0ed646ed09 read legacy hooks in an encoding-agnostic way 2021-06-15 08:32:44 -07:00
Anthony Sottile
12a7075fda skip installation for SKIP'd hooks 2021-04-10 00:37:59 -07:00
Paweł Sacawa
6b73138c73 Add: post-merge hook support 2021-02-23 19:00:02 -08:00
surafelabebe
cb5ed6276d Expose remote branch ref as an environment variable 2021-01-22 13:18:25 -08:00
Anthony Sottile
89ab609732 fix the default value for types_or 2020-11-25 18:21:37 -08:00
Paul Fischer
53109a0127 fixed message if repo couldn't be updated due to missing hook(s) 2020-11-22 13:34:10 -08:00
Michael Vincent
120d60223a Improve performance by ignoring submodules
When git status runs in a repo with submodules, it'll recursively run
git status in every submodule as well by default (sequentially).
git status is substantially slower on Windows than on Linux. git diff
behaves similarly to git status in terms of running recursively within
all submodules. In repos with hundreds of submodules, this quickly adds
up when git status/diff are called multiple times. Pre-commit runs
git status once at the beginning of an operation and then runs git diff
before and after each hook. These calls quickly add up and make
pre-commit unusable in large repos with lots of submodules.

This commit drastically improves performance in repos with lots of
submodules and fixes #1701 by telling git status and git diff to ignore
submodules. This change is not expected to have any negative effect on
existing hooks because each submodule should manage its own hooks
instead of relying on superproject hooks to manipulate their contents.
2020-11-19 23:26:05 -06:00
Anthony Sottile
64d57ba466 remove DOTALL on REV_LINE_RE 2020-11-06 14:36:43 -08:00
Anthony Sottile
c972205214 Merge pull request #1684 from pre-commit/migrate_config_less_work
only perform migrate_config parsing if it is a list
2020-11-05 16:27:23 -08:00
Anthony Sottile
1975c056bc Merge pull request #1683 from pre-commit/textwrap_indent
use textwrap.indent instead of _indent
2020-11-05 16:22:17 -08:00
Anthony Sottile
b4ab84df58 only perform migrate_config parsing if it is a list 2020-11-05 16:05:41 -08:00
Anthony Sottile
64876697b5 use textwrap.indent instead of _indent 2020-11-05 15:59:46 -08:00
Marco Gorelli
62f668fc3f add types_or 2020-11-02 17:25:10 +00:00
Anthony Sottile
24dfeed89c Replace EnvironT with MutableMapping[str, str] 2020-10-28 13:00:25 -07:00
Maximilian Cosmo Sitter
3de3c6a5fc Update pre-commit version in sample config 2020-09-27 14:54:42 -07:00
Celeborn2BeAlive
273326b89b drop python.exe extension on windows on shebang 2020-09-09 12:42:48 -07:00
Anthony Sottile
79b098c409 fix atomic file replace on windows 2020-08-23 10:18:59 -07:00
Johan Henkens
4063730925 Save diff between hook executions 2020-08-21 20:41:06 -07:00
Greg Singer
1b435f1f1f add init-templatedir --no-allow-missing-config
Add a `--no-allow-missing-config` option to the `init-templatedir`
command. Enable configuration of a Git template that requires newly
cloned repos to have a `pre-commit` config.
2020-07-20 19:02:35 -07:00
Anthony Sottile
5fb721f7a7 normalize slashes even earlier on windows for filenames 2020-06-08 14:53:27 -07:00
Chad Larson
9e0b4a9d4d pre-commit env var exposed 2020-05-23 17:20:26 -05:00
Anthony Sottile
9b8e3d082d refuse to migrate an invalid configuration 2020-05-10 18:02:37 -07:00
Marc Jay
98d8a3d60f Maintain scalar quoting style when autoupdate re-writes rev
If rev is wrapped in single or double quotes (e.g. due to a yamllint quoted-strings rule), when
re-writing the rev to update it, honour the existing quotation style
2020-05-04 19:29:03 -07:00
Dom
928938a6a1 fix hooks firing during staged_files_only 2020-05-02 14:00:21 -07:00
ModischFabrications
26adf1d560 add support for post-commit 2020-04-27 10:55:22 -07:00
Lukasz Boldys
13d528c569 Preserve line ending when running autoupdate 2020-04-19 09:12:02 -07:00
Anthony Sottile
80a59db094 validate argument length as part of hook-impl 2020-04-15 12:30:44 -07:00
zjeuhpiung liu
605b39f617 fix CJK characters width in output 2020-03-28 08:06:49 -07:00
Anthony Sottile
67c1beb322 Use covdefaults to handle coveragerc 2020-02-29 14:25:19 -08:00
Anthony Sottile
53052fe019 Ensure files aren't passed to post-checkout hooks 2020-02-23 11:38:16 -08:00
Anthony Sottile
d35b00352f Make more readable --from-ref / --to-ref aliases for --source / --origin 2020-02-23 11:07:57 -08:00
Anthony Sottile
566f1afcd4 Merge pull request #1339 from andrewhare/andrewhare/post-checkout
Add post-checkout
2020-02-23 10:39:28 -08:00
Andrew Hare
18fa004254 Add post-checkout 2020-02-23 10:22:18 -08:00
Joey Espinosa
5258dce73b fix: catch missing arg if using {prepare-}commit-msg stage
If using the prepare-commit-msg and commit-msg stages specifically (such
    as with the try-repo command), the `--commit-msg-filename` arg must be
provided.

[fixes #1336]

chore: improve error message for hook stage check
2020-02-23 10:15:59 -08:00