Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1258 +/- ##
==========================================
+ Coverage 90.03% 90.05% +0.02%
==========================================
Files 80 80
Lines 15627 15654 +27
==========================================
+ Hits 14069 14097 +28
+ Misses 1558 1557 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.00% (16.7 MiB → 16.7 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
|
Hey @jmelahman, |
There was a problem hiding this comment.
Pull request overview
This PR changes how prek handles Git environment variables when running hooks. Instead of unsetting GIT_DIR in generated hook scripts, prek now respects the GIT_DIR value set by git and intelligently sets GIT_WORK_TREE when necessary to ensure correct git behavior.
- Removed
unset GIT_DIRfrom all generated hook scripts - Added logic to set
GIT_WORK_TREEwhenGIT_DIRis set butGIT_WORK_TREEis not - Incremented hook script version from 3 to 4 to trigger re-installation
- Added comprehensive test coverage for the new behavior
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/prek/src/main.rs |
Added logic to detect when GIT_DIR is set and intelligently set GIT_WORK_TREE to the current directory before any --cd operations |
crates/prek/src/cli/install.rs |
Removed unset GIT_DIR from hook template and incremented script version to 4 |
crates/prek-consts/src/env_vars.rs |
Added constants for GIT_DIR and GIT_WORK_TREE environment variables |
crates/prek/tests/hook_impl.rs |
Added new test git_dir_respected() to verify hooks work correctly with GIT_DIR set; reorganized setup calls in run_worktree() test; added PREK_HOME env var to workspace test command; cleaned up string literal delimiter |
crates/prek/tests/install.rs |
Updated all test snapshots to reflect removal of unset GIT_DIR and script version bump to 4 |
crates/prek/tests/run.rs |
Added PREK_HOME environment variable to git commit command in test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I agree, much cleaner :) I confirmed this resolved my issue. Thank you! |
Closes #1239
Closes #1252