pre-commit/pre_commit
Claude c064dd83df
Cap hook output at terminal width to prevent wrapping
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>
2025-10-28 13:28:22 +00:00
..
commands Cap hook output at terminal width to prevent wrapping 2025-10-28 13:28:22 +00:00
languages py310+ 2025-10-09 17:44:05 -04:00
meta_hooks python3.9+ 2023-10-28 14:20:37 -04:00
resources upgrade rbenv / ruby-build 2025-10-24 15:18:07 -04:00
__init__.py Initial commit. 2014-03-12 20:25:19 -07:00
__main__.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
all_languages.py Add support for julia hooks 2024-11-25 18:31:25 -05:00
clientlib.py add warning for deprecates stages for remote repos on init 2024-09-30 20:41:50 -04:00
color.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
constants.py make --hook-type and stages match 2023-03-11 14:26:14 -05:00
envcontext.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
error_handler.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
errors.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
file_lock.py py310+ 2025-10-09 17:44:05 -04:00
git.py fix deprecated call 2025-10-16 10:23:30 -04:00
hook.py python3.9+ 2023-10-28 14:20:37 -04:00
lang_base.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
logging_handler.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
main.py Merge pull request #3536 from pre-commit/store-true-default 2025-09-06 14:28:02 -04:00
output.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
parse_shebang.py python3.9+ 2023-10-28 14:20:37 -04:00
prefix.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
repository.py remove deprecated python_venv alias 2024-10-05 13:30:25 -04:00
staged_files_only.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
store.py py310+ 2025-10-09 17:44:05 -04:00
util.py py310+ 2025-10-09 17:44:05 -04:00
xargs.py py310+ 2025-10-09 17:44:05 -04:00
yaml.py change migrate-config to use yaml parse tree instead 2024-09-16 20:16:16 -04:00
yaml_rewrite.py change migrate-config to use yaml parse tree instead 2024-09-16 20:16:16 -04:00