Previously, _compute_cols() would calculate the ideal column width based
on hook names and message lengths, with a minimum of 80 columns. However,
it didn't consider the actual terminal width, causing the "Passed/Failed"
status to wrap to the next line on narrower terminals.
This change:
- Adds terminal width detection using shutil.get_terminal_size()
- Caps the column width at the terminal width to prevent wrapping
- Maintains the minimum of 80 columns when terminal is wide enough
- Falls back to 80 columns if terminal size cannot be determined
The algorithm now ensures output always fits within the terminal width,
similar to how pytest handles its output formatting.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Kamil Monicz <kamil@monicz.dev>
Co-Authored-By: Claude <noreply@anthropic.com>
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.
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