-
Notifications
You must be signed in to change notification settings - Fork 11
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
packer_fmt says there are no files to check when file exists #24
Comments
Thanks for the issue @nandac! Are you running |
@mcdonnnj, is there possibly a typo here?
Should that instead be this? files: (packer\.json|\.pkr|\.hcl)$ |
Thanks, @jsf9k for your reply. I think you are right in saying that I probably tried it through git commit instead of trying it just with the raw command. I now have a different issue regarding getting it to work with packer_fmt's arguments such as -write or -recursive which come up with the following message even if the file is formatted correctly.
This is how I am specifying it in my pre-commit-config.yaml repos:
- repo: https://github.com/cisagov/pre-commit-packer
rev: v0.0.2
hooks:
- id: packer_fmt
args: ["-write=true"] I can see why write would fail because you have set it to check by default but recursive should work and I think it is because arguments are not handled and I believe that This could be fixed by checking if the beginning of the elements in We can handle the default case of check with no arguments as well. If I were submit a fix would you be able to review and release? |
Packer HCL2 files are explicitly |
@nandac Yes this issue is part of a series of enhancements for this project that have been stuck in my backlog. |
@jsf9k Maybe I could take a look into a fix if I have time over the weekend. I am not an expert shell scripter but I have some ideas I would like to try out. |
Please go ahead, @nandac! We'll be happy to review your PR when you're ready. |
@jsf9k I have added this PR #25 for packer_fmt.sh so that it can interpret packer options. I did some preliminary testing by hand with a test file and all the tests gave the expected results. I need your help in getting this well tested and getting the PR into a semblance of something that can be published. Would you be able to help. I have not worked with pre-commit hooks and don't really know how to test locally with the whole pipeline. |
@jsf9k Further to my previous comment I have tested it on my private repo like this: - repo: https://github.com/nandac/pre-commit-packer
rev: f0b7c8b6a206b2fa2a802a0a71d75cfac49dc5b5
hooks:
- id: packer_fmt
args: ["-write=true"] And it works well. I will keep testing. |
Please note that as of the 0.1.0 release you should be able to pass commands to both hooks, and the |
🐛 Summary
When running the packer_fmt hook the message I receive is:
Packer Format........................................(no files to check)Skipped
Even though I have
.pkr.hcl
file in my repositoryTo reproduce
Steps to reproduce the behavior:
.pre-commit-config.yml
something like this:.pkr.hcl
extension.Expected behavior
I should not receive the
no files to check
message.Any helpful log output or screenshots
Paste the results here:
When running the command
pre-commit run --all-files --color always
I get the following output:The text was updated successfully, but these errors were encountered: