Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
m-iwanicki opened this issue Sep 11, 2024 · 3 comments

Comments

@m-iwanicki
Copy link
Contributor

 ./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
Copy link
Member

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
Copy link
Contributor Author

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants