Scripts that can work as git
hooks to modify (text) files.
These scripts can be called directly or with the provided configuration for the pre-commit framework.
For details see below.
Add this to your .pre-commit-config.yaml
:
- repo: https://github.com/boidolr/pre-commit-text
rev: v1.2.17 # Use the ref you want to point at
hooks:
- id: pretty-format-yaml
- id: replace-tabs
# - id: ...
For an extended example see .pre-commit-config.yaml
.
pretty-format-yaml
: Format yaml files.--mapping
space to use as offset for mappings.--sequence
space to use as offset for sequences (default is value for mapping plus two).--preserve-quotes
whether to keep quoting as is or change to default.
properties-whitespace
: Remove whitespace around equal signs in property files. Implemented using thesearch-replace
hook.replace-tabs
: Replace tabs in files.--tabsize
spaces to replace a tab with.
search-replace
: Replace patterns in files.--search
regular expression to use for search.--replacement
replacement for matches.
Install the package to get access to the scripts defined as command line entry points in pyproject.toml
.
The scripts accept the arguments given for the pre-commit hooks. Additionally they exepect to receive the file names to work on.
An example invocation could be uvx --from 'git+https://github.com/boidolr/pre-commit-text.git' format-yaml --preserve-quotes .github/release.yml
.
Available entry points are:
format-yaml
replace-tabs
search-replace