Text files with trailing white spaces (one of \t \v \n \r and space)
lead to unnecessary diffs and make merging more difficult. We should
remove them.
However, developers should NOT be drained on such repetitive tasks as
'removing trailing white spaces'. Indeed, code reviews should focus on
'what was said' rather how 'how it was said'.
This comit enables the following workflow:
- After a fresh clone of this repository, the developer runs the
following commands to perform a one-time setup of the pre-commit
hooks for this clone of the repository:
# https://pre-commit.com/
sudo pip3 install pre-commit
pre-commit install
These commands will install a .git/pre-commit script that searches
for file .pre-commit-config.yaml in the root directory of this
repository.
- Every `git commit` afterwards will trigger the hooks configured in
the .pre-commit-config.yaml file. In this case, the python script
./tools/lint/purify_text.py will be called to process each staged
file to strip trailing whitespaces.
- In the future, if this repository needs more linters and formatters,
just configure the .pre-commit-config.yaml file to add more or
modify existing ones.