GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — Fix commit hooks respecting core.hooksPath by Siesta0217 · Pull Request #2159 · gitpython-developers/GitPython Conversation
|
| 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.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
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
9b3198c to
406b98e
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
git/index/fun.py:99
run_commit_hook assumes the hook path is under index.repo.working_dir when it builds relative_hp for bash.exe. With core.hooksPath, git rev-parse --git-path hooks/<name> can legitimately return an absolute path outside the working directory (or a relative path that escapes it), which makes Path(hp).relative_to(...) raise ValueError and turns a runnable hook into a HookExecutionError. Consider using os.path.relpath with a fallback to an absolute POSIX path instead of Path.relative_to so hooks configured outside the worktree don't crash. hp = _commit_hook_path(name, index)
if not os.access(hp, os.X_OK):
return
env = os.environ.copy()
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
0702dea to
f7aa470
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
11a0c30 to
fafbdc8
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
- 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.
5252136 to
9bc287a
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
git/index/fun.py:71
_commit_hook_path() uses config.get("core", "hooksPath"), but GitConfigParser is explicitly case-sensitive for section and option names. This means valid Git configs like [Core] hooksPath=... or core.hookspath=... will be ignored and hooks will incorrectly fall back to .git/hooks, so the fix won’t work in many real-world configurations.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.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Commit hooks don't respect core.hooksPath in config.
There was an error while loading. Please reload this page.