3mdeb / hooks

MIT License
2 stars 0 forks source link

pre-commit-init.py creates pre-commit files that don't pass self checks #13

Open m-iwanicki opened 1 month ago

m-iwanicki commented 1 month ago
 ./pre-commit-init.py <path/to/repo> markdown

initializes pre-commit that fails it's own checks:

fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

(...)
Fixing .pre-commit-config.yaml

There were 2 newlines at the end of .pre-commit-config.yaml

pietrushnic commented 1 month ago

Fixing the end of the file also causes problems for me in sli.dev, which I have used for Dasharo/presentation since DUG#7. On one side, there is a requirement for a surrounding heading, so if I have a heading in the last line surrounded, then this fixer comes saying there is a need to remove the empty line at the end of the file.

m-iwanicki commented 1 month ago

I think that's different from this issue. My issue was that pre-commit-init.py generates 'faulty' config (with 2 newlines at the end of the file when we want only 1 line). In most cases I think it's correct to trim excess newlines and when it isn't then config can be modified per repository to ignore files/extensions. Unless we always want to not trim some files then it could be added here. Possibly also add .patch files because I think they always are generated with 2 newlines at the end. Or maybe ignore .patch files completely.

pietrushnic commented 1 month ago

I understand you have different issue. Just saying this is nit first time this feature leads to problems. If there be more cases like this maybe we should agree it is not critical or configure it better.