| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks a lot.
The test is good, but the implementation needs adjustments.
Sorry, something went wrong.
There was a problem hiding this comment.
This PR updates GitPython’s commit-hook execution to resolve hook locations via Git itself, so hooks honor core.hooksPath, and adds a regression test to confirm a hook runs from a custom hooks directory.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| git/index/fun.py | Adds Git-based hook path resolution and uses it in run_commit_hook(). |
| test/test_index.py | Adds a regression test for core.hooksPath hook execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Use git rev-parse --git-path when resolving commit hook paths so GitPython follows Git's core.hooksPath configuration.\n\nAdd regression coverage for a pre-commit hook stored in a custom hooks path.\n\nFixes gitpython-developers#2083
There was a problem hiding this comment.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)git/index/fun.py:99
hp = _commit_hook_path(name, index)
if not os.access(hp, os.X_OK):
return
env = os.environ.copy()
Sorry, something went wrong.
- Review feedback: resolve core.hooksPath only when configured, avoid an unconditional git rev-parse dependency, and cover relative paths in a non-bare repository. - Read the effective Git configuration directly so unconfigured repositories retain the legacy .git/hooks lookup and configured relative paths resolve from the directory where hooks execute. Exercise both guarantees in the hook tests. - Review feedback: core.hooksPath can point outside index.repo.working_dir, where Path.relative_to() raises on Windows and prevents a valid hook from running. - Build the Bash argument with os.path.relpath so hooks in parent or other absolute locations remain executable. Fall back to the absolute POSIX-form path when Windows cannot form a relative path across drives, and add a focused command-construction regression test.
There was a problem hiding this comment.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)git/index/fun.py:71
def _commit_hook_path(name: str, index: "IndexFile") -> str:
""":return: path to the named commit hook, respecting Git's core.hooksPath."""
with index.repo.config_reader() as config:
hooks_dir = config.get("core", "hooksPath", fallback="")
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Tasks
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Summary
Fixes #2083
Test Plan