Skip to content

Conversation

@TheoBrigitte
Copy link

@TheoBrigitte TheoBrigitte commented Sep 30, 2025

Pull Request

Description

This PR fixes an issue which prevents the git pre-commit hook from succeeding. This is due to the hardcoded path to the scripts/test.sh` script.

Before

Without this change the git pre-commit hook would always fail due to the invalid hardcoded path to the test.sh script.

$ git commit -m'address the rabbit reviews 🥕'
Running StyLua on staged Lua files...
Lua files have been formatted and staged.
Running luacheck on staged Lua files...
Checking lua/claude-code/config.lua               OK

Total: 0 warnings / 0 errors in 1 file
Checking lua/claude-code/keymaps.lua              OK

Total: 0 warnings / 0 errors in 1 file
Running tests to ensure code quality...
Running test script at: /home/gregg/Projects/neovim/plugins/claude-code/scripts/test.sh
bash: /home/gregg/Projects/neovim/plugins/claude-code/scripts/test.sh: No such file or directory
❌ Tests failed! Commit aborted.
Please fix the test failures before committing.

After

$ git commit -m'address the rabbit reviews 🥕'
Running StyLua on staged Lua files...
Lua files have been formatted and staged.
Running luacheck on staged Lua files...
Checking lua/claude-code/config.lua               OK

Total: 0 warnings / 0 errors in 1 file
Checking lua/claude-code/keymaps.lua              OK

Total: 0 warnings / 0 errors in 1 file
Running tests to ensure code quality...
Running test script at: /home/some/path/claude-code.nvim/scripts/test.sh
Changing to plugin directory: /home/some/path/claude-code.nvim
Running tests from: /home/some/path/claude-code.nvim
Running tests with /usr/bin/nvim
Running tests with a 60 second timeout...
[ ... removed lines ... ]
Running tests in: version_spec.lua
Success ||      version string should return the correct version string
Success ||      version version components should have correct version components
Success ||      version print_version should call vim.notify with correct message

==== Test Results ====
Total Tests Run: 67
Successes: 67
Failures: 0
Errors: 0
=====================

All tests passed!
Test run completed successfully
✅ All tests passed. Proceeding with commit.
[window-navigation-keymap b32bd39] address the rabbit reviews 🥕
 2 files changed, 7 insertions(+), 7 deletions(-)

Type of Change

Please check the options that are relevant:

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Other (please describe):

Checklist

Please check all that apply:

  • I have read the CONTRIBUTING document
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have tested with the actual Claude Code CLI tool
  • I have tested in different environments (if applicable)

Summary by CodeRabbit

  • Chores
    • Updated pre-commit hook to run the test script via a relative path, improving portability across different environments and directory setups.
    • Maintains existing test behavior, error handling, and success messaging.
    • Minor whitespace cleanups in the hook script; no functional impact.

@coderabbitai
Copy link

coderabbitai bot commented Sep 30, 2025

Walkthrough

Updates the Git pre-commit hook to invoke the test script via a relative path variable instead of an absolute path. The hook’s logic for discovering paths, running tests, handling failures, and printing success remains unchanged. Minor whitespace adjustments are included.

Changes

Cohort / File(s) Summary of changes
Git hooks
\.githooks/pre-commit
Switched test script invocation from absolute path to a RELATIVE_PATH-based call (scripts/test.sh). Preserved existing workflow (path discovery, error handling, success message). Minor whitespace tweaks.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer
    participant Git as Git
    participant Hook as pre-commit hook
    participant Tests as scripts/test.sh

    Dev->>Git: git commit
    Git->>Hook: Run pre-commit
    Note right of Hook: Resolve RELATIVE_PATH to test script
    Hook->>Tests: Execute ./scripts/test.sh
    alt Tests fail
        Tests-->>Hook: non-zero exit
        Hook-->>Git: block commit with error
    else Tests pass
        Tests-->>Hook: zero exit
        Hook-->>Git: allow commit
    end

    rect rgba(232,245,233,0.6)
    Note over Hook,Tests: Changed: absolute path ➜ relative path invocation
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my whiskers, tests now run,
From paths that walk where projects spun.
No hard-coded burrow, just trails that last—
A nimble hop from future to past.
Commit gates guard with gentle might,
Green carrots glow when scripts run right. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly summarizes the primary change by stating that the pre-commit hook error is fixed, which directly corresponds to removing the hardcoded test script path to allow the hook to succeed. It is concise, specific to the main objective, and avoids extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9a31e5 and c0ea504.

📒 Files selected for processing (1)
  • .githooks/pre-commit (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-07-02T19:40:53.423Z
Learnt from: CR
PR: greggh/claude-code.nvim#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-02T19:40:53.423Z
Learning: Applies to lua/**/*.lua : Check formatting of Lua code using stylua

Applied to files:

  • .githooks/pre-commit
📚 Learning: 2025-07-02T19:40:53.423Z
Learnt from: CR
PR: greggh/claude-code.nvim#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-02T19:40:53.423Z
Learning: Applies to lua/**/*.lua : Format Lua code using stylua

Applied to files:

  • .githooks/pre-commit
📚 Learning: 2025-07-02T19:40:53.423Z
Learnt from: CR
PR: greggh/claude-code.nvim#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-02T19:40:53.423Z
Learning: Applies to lua/**/*.lua : Run luacheck linter on Lua code

Applied to files:

  • .githooks/pre-commit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@TheoBrigitte TheoBrigitte changed the title Remove hardcoded scripts/test.sh full path Fix failing git pre-commit hook Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant