Fix/doc sync hook automation - #15
Conversation
WalkthroughThese changes introduce Git hook management for automatic documentation synchronization. Users can now install a post-commit hook during Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/doc-sync.js (1)
348-379: Use a portable hash fallback for cross-platform compatibility.The hook uses
shasumwhich is standard on macOS but unavailable on many Linux systems (e.g., Alpine, Ubuntu withoutperlmodule). The existingpost-tool-use-tracker.shhook in the codebase demonstrates the correct fallback pattern already used elsewhere:🔧 Portable hash command
- REPO_HASH="\$(echo "\$REPO_ROOT" | shasum | cut -c1-8)" + REPO_HASH="\$(echo "\$REPO_ROOT" | (shasum 2>/dev/null || sha1sum) | cut -c1-8)"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/doc-sync.js` around lines 348 - 379, The hookBlock uses shasum to compute REPO_HASH which breaks on systems without shasum; update the shell snippet inside hookBlock (function __aspens_doc_sync and variable REPO_HASH) to use a portable fallback (try shasum, else sha1sum, else openssl sha1) when computing the hash of REPO_ROOT so it works on macOS and Linux variants — implement the same fallback pattern used in post-tool-use-tracker.sh so REPO_HASH is set reliably across platforms.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/commands/doc-sync.js`:
- Around line 348-379: The hookBlock uses shasum to compute REPO_HASH which
breaks on systems without shasum; update the shell snippet inside hookBlock
(function __aspens_doc_sync and variable REPO_HASH) to use a portable fallback
(try shasum, else sha1sum, else openssl sha1) when computing the hash of
REPO_ROOT so it works on macOS and Linux variants — implement the same fallback
pattern used in post-tool-use-tracker.sh so REPO_HASH is set reliably across
platforms.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 72fa6493-f1db-423a-b09d-6ece5b9d7fdb
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
bin/cli.jssrc/commands/doc-init.jssrc/commands/doc-sync.jstests/git-hook.test.js
What
Fixes the doc-sync post-commit hook (exit 0 bug, silent failures, no uninstall) and makes hook installation automatic after doc init.
Why
The hook had a bug where exit 0 in the cooldown path killed parent hooks when appended. Background sync failures were invisible (no logging). And the hook required a separate manual step that most users wouldn't discover.
Closes #
How I tested
npm testpasses--dry-runoutput looks correct (if applicable)Checklist
Summary by CodeRabbit
Release Notes
New Features
--no-hookoption to skip git hook setup prompts during documentation initialization.--remove-hookoption to uninstall the automatic git post-commit hook.Tests