{
  "id": 113888,
  "title": "My Hook's Path Fix Passed Its Own Test. It Broke My README's Other Install Method.",
  "url": "https://urgent.news/2026/08/04/my-hooks-path-fix-passed-its-own-test-it-broke-my-readmes-other",
  "topic": "ai",
  "section": "AI",
  "published": "2026-08-04T03:41:12.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/enjoy_kumawat/my-hooks-path-fix-passed-its-own-test-it-broke-my-readmes-other-install-method-2fn8"
  },
  "original_language": "en",
  "account": "Four days ago, a bug was fixed in a git hook named hooks/prepare-commit-msg. This hook utilized a small script (git_commit.py) that asked Claude to pre-fill a Conventional Commit message. However, the hook had never worked correctly because it computed its own script path one directory too shallow. The bug was fixed, verified against a real install, and the fix was documented. The following day, while looking for something else to check in the repository, the author noticed that their own README.md contained two ways to install the hook. The fix only worked for one of the installation methods. The author analyzed the relevant line of code in the hook, which was designed to compute the script path correctly. The author then tested both installation methods using a real clone of the repository and verified that the hook was invoked correctly in both cases. The author concluded that the path-arithmetic fix, which was initially tuned for one installation method, did not work for the other installation method. A third installation method, such as a symlink or a monorepo nesting, would require a different depth. The author realized that the original fix only worked for one specific installation method and did not address the issue for the other method. They proposed a solution to stop relying on $0 to determine the script path and instead use git's rev-parse --show-toplevel command to find the repository's root directory. By implementing this change, both installation methods would work correctly, regardless of the path to the hook file. The author emphasized that their original fix had successfully passed its own verification, but the change in the README's installation instructions created a dependency issue that needed to be addressed.",
  "summary": "Four days ago I fixed a bug in a git hook I wrote: hooks/prepare-commit-msg , which shells out to a small script ( git_commit.py ) that asks Claude to pre-fill a Conventional Commit message. The hook had never once actually worked, because it computed its own script path one directory too shallow. I fixed it, verified it against a real install, wrote it up, moved on. This morning I went looking…",
  "key_points": [
    "Bug fixed in git hook, script path corrected",
    "README.md contains two install methods, fix only worked for one",
    "Proposed solution uses git's rev-parse --show-toplevel command"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}