Closed kayman-mk closed 1 year ago
Hey @kayman-mk !
It could be pre-commit "died" in the middle of the process once? After that, the bad tf files mess up the next runs...
Hm, the output says "passed". Are there logs available?
$ git commit -m "testr"
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to C:\Users\kayma\.cache\pre-commit\patch1653467778-2272.
yor......................................................................Passed
[INFO] Restored changes from C:\Users\kayma\.cache\pre-commit\patch1653467778-2272.
[kayma/a 0ee2f54] testr
2 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 .pre-commit-config.yaml
pre-commit run -v --files main.tf
did it.
[WARNING] Unable to get git blame for file main.tf: failed to get blame for latest commit of file main.tf because of error file not found
git blame main.tf
works.
Ok, what is the error file?
Tried with 0.1.150
. Error is still there. Also did a git blame my-file-name.tf
before doing the yor
command. git blame
works fine.
Note: My pipeline jobs are using the Alpine image. I had to install libc6-compat
to get it working. Is there anything else to install?
This doesn't seem to have anything to do with the pre-commit hook, something broken in yor windows amd64 binary when running on windows 10. Our build process is using linux but the developers desktops are windows and the only place we see this error is when running on windows 10. Be nice if we could get this resolved.
To easily replicate, on any Windows 10 build and using yor version 0.1.151:
Edition Windows 10 Enterprise Version 20H2 Installed on 3/13/2022 OS build 19042.1889 Experience Windows Feature Experience Pack 120.2212.4180.0
Just create a simple module with main.tf in it,
Add something as simple as:
resource "aws_security_group" "default" {
name = "test"
}
Then do the git init, git add. git commit, etc to setup for yor.
Run yor:
yor tag -d .
Error:
2022/10/31 11:27:23 [WARNING] Failed writing tags to file main.tf, because remove .\temp.874456116.tf: The process cannot access the file because it is being used by another process.
Run it again, and It just keeps creating temp.NNNNNNNNNN.tf files over and over.
git pull the same repo down to a linux machine using the linux amd64 binary and it works fine.
I found and fixed this in https://github.com/bridgecrewio/yor/pull/321 #321
Describe the bug Executing
yor
via pre-commit hook results in many temporary files, but none of my Terraform files is changed.Looks like that
yor
created one temporary file per Terraform source file. No error message is shown.Using
yor
via Docker works as expected.To Reproduce
Install the pre-commit hook and change a Terraform file. After
git commit
the temporary file appears.Expected behavior Have the Terraform source code changed (tags added).
Desktop (please complete the following information):