Closed x80486 closed 4 years ago
OK, this one took me a while.
I was initially setting up the Git hooks business manually so I ended up doing some shell scripts. Then I wanted them to be in source control, so I added them in a .git-hooks/
sub-directory in the project's root and modifying Git's core.hooksPath
setting.
The message Fatal error encountered during initialization. Details: Unable to create git hooks
was what gave me the clue. Probably you folks might want to provide a similar error message with the location that's trying to be resolved to store the hooks.
It works flawlessly right now :tropical_drink: :trophy:
Thanks for the library! Feel free to close this one.
Thanks for reaching out @x80486 and glad it's working! I have a few follow up questions for you just to ensure I understand the steps you went through to see whether we'll want to update any docs/error messages/etc. on our end.
When you first added rusty-hook
as a dev dep and ran cargo test
as I believe referenced in the issue description, am I understanding correctly that there was no .rusty-hook.toml
config file created (you had to create it yourself) and you also didn't get any errors?
No, I installed it via dev-dependencies
and put a default .rusty-hook.toml
with:
[hooks]
pre-commit = "cargo test --all"
[logging]
verbose = true
...then I tried to commit (with a failing test).
No, I installed it via dev-dependencies and put a default .rusty-hook.toml with:
So you created your own config file before you ran cargo test
?
the build process will seed a default config file for you (if one doesn't already exist), but it sounded like one wasn't generated for you and that you had to create one for yourself.
I'd forgotten that the build.rs process always returns 0 even if the initialization fails during build, which it did in your case for precisely the reason you discovered. The build script does print a similar error message to the console, however, cargo swallows output during the build unless you run with -vv
, so the same error that occurred during your first cargo test
never popped up in the terminal.
There's really no reason our build script should exit with 0 in the event it failed and was unable to create the hook files and and config file, and the current behavior is obviously ambiguous and confusing. Users can always remove it from their dev-deps if it's failing and that's a blocking issue for them.
Thanks again for letting us know about this @x80486! I'm going to go ahead and close this given that the issue is resolved, but going to open a new issue (#110) to track updating the build script
Environment Details
rustc 1.44.1 (c7087fe00 2020-06-17)
cargo 1.44.1 (88ba85757 2020-06-11)
^0.11.2
Description
I have a small pilot project that I use for testing. I'm trying to setup
rusty-hook
but it's not working in any shape or form. The way I installed it was by addingrusty-hook = "^0.11.2"
on the[dev-dependencies]
section insideCargo.toml
. Then I do:Then I create a
.rusty-hook.toml
file in the project's root with this content:...modify a test case to make it fail, stage the changes, and finally do
git commit --message="blah"
. The expectation is that something gets created in.git/hook
and the hook to be executed...but nothing. Any clues?By the way, I also tried to install it via
cargo install rusty-hook
, but I'm gettingFatal error encountered during initialization. Details: Unable to create git hooks
when trying to initialize.