fix(git-hooks): prefer core.hooksPath and avoid symlink on Windows#5438
fix(git-hooks): prefer core.hooksPath and avoid symlink on Windows#5438Shiven0504 wants to merge 5 commits into
Conversation
| itoa = "1" | ||
| json5 = "0.4" | ||
| jsonwebtoken = { version = "10.4.0", features = ["rust_crypto"] } | ||
| jsonwebtoken = "10.4.0" |
There was a problem hiding this comment.
these changes seem unrelated - can you revert?
| @@ -0,0 +1,45 @@ | |||
| Title: Hook installer removes .git/hooks and uses symlink — breaks on Windows; prefer git core.hooksPath | |||
bfops
left a comment
There was a problem hiding this comment.
I appreciate the issue and the intention here, but I'm not sure that this is the right way to address it. This would mean that if I want to add (or modify) any hooks for my own workflow, I would need to put them into the repo-tracked directory and constantly have unstaged changes.
Maybe the right solution is to copy the files instead of symlink, but honestly we don't have an active pain point with the way it is right now (most contributors and many team members don't install the hooks in the first place) so I'm not sure that we want to spend time iterating on a solution.
…ypto"] } at line 236 Signed-off-by: Shiven Garia <shivengaria@gmail.com>
Signed-off-by: Shiven Garia <shivengaria@gmail.com>
|
Hi @bfops, that's a valid concern I hadn't fully thought through. I realized that pointing The copy approach avoids that hence contributors can freely modify their local copies without polluting the working tree. The catch is that hook updates don't actually propagate automatically, but given that most contributors skip installation |
|
Happy to close this if the team doesn't see it as an active pain point! |
Summary
git-hooks/install-hooks.shunconditionally removes../.git/hooksand attempts to create a symlink to../git-hooks/hooks. On Windows (and some restricted environments) creating symlinks requires elevated privileges or is unsupported, and the script can unintentionally remove existing hooks. This causes the installer to fail or damage developer setups.Steps to reproduce
ln -sfails (or that.git/hookswas removed), and that hooks are not installed.Expected behavior
My Proposed fix
git config core.hooksPath git-hooks/hooksby default (works cross-platform and avoids symlinks).gitis not available, and show a clear warning.rustup component add rustfmtifrustupis installed.Patch / PR
I have a proposed patch that updates
git-hooks/install-hooks.shto prefergit config core.hooksPathand to guardrustupusage. The patch is ready in a branchfix/git-hooks-installer.