feat(cli): add hook status command - #162
Conversation
|
Warning Review limit reached
More reviews will be available in 51 minutes. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds a new read-only Changesgit smee status subcommand
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d7e6d0fb9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let Ok(content) = fs::read_to_string(&hook_path) else { | ||
| continue; | ||
| }; | ||
| if content.contains(MANAGED_FILE_MARKER) { |
There was a problem hiding this comment.
Use header-aware managed detection for obsolete hooks
When an unconfigured hook merely mentions THIS FILE IS MANAGED BY git-smee in its body, this substring check reports it as an obsolete managed wrapper and adds a remove obsolete managed hook ... action, even though the installer’s managed-file logic treats marker-in-body files as unmanaged and would not prune them. This can make git smee status recommend deleting a user-owned hook; use the same header-scoped managed detection semantics here (and for configured hook classification) instead of raw contains.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in cce5c53 by exposing/reusing installer header-scoped managed detection (has_managed_header) for status classification and obsolete-hook detection. Added integration tests for marker text that appears only in hook bodies.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/git-smee-cli/src/main.rs`:
- Around line 325-326: The print_status_report function uses the Debug format
specifier {:?} to display report.status, which relies on the Debug trait
implementation and is fragile for user-facing output. Instead, add an explicit
as_text() method to the StatusState type for consistency with how HookState is
handled (which already uses as_text() for output), then replace the {:?} debug
format call in the println! statement with a call to report.status.as_text() to
provide stable, intentional formatting for user output.
In `@crates/git-smee-cli/tests/cli_integration.rs`:
- Around line 187-215: The test
`given_stale_and_obsolete_managed_hooks_when_status_then_reports_drift_without_modifying`
contains a hardcoded path assertion with forward slashes `.git/hooks/commit-msg`
on line 214. Since `display_repo_path()` uses `Path::display()` which renders
platform-native separators (backslashes on Windows), this assertion will fail on
Windows. Replace the assertion that checks for the exact path "remove obsolete
managed hook .git/hooks/commit-msg" with a more platform-agnostic matcher by
using `predicate::str::contains("commit-msg")` instead, or normalize the path to
use only forward slashes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0492fb13-9792-4606-9d51-46c65ee404d0
📒 Files selected for processing (3)
README.mdcrates/git-smee-cli/src/main.rscrates/git-smee-cli/tests/cli_integration.rs
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cce5c53421
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !content.contains(&expected_config) { | ||
| stale_reasons.push(format!("expected config path {expected_config}")); |
There was a problem hiding this comment.
Match the wrapper config argument exactly
When the configured path is a prefix of the stale path, such as reinstalling with .git-smee.toml after a wrapper was generated for .git-smee.toml.bak, this substring check passes and status reports the hook as installed/Ok even though Git will still run with the old config. Match the actual escaped --config argument, or parse the wrapper invocation, instead of accepting any occurrence of the expected path.
Useful? React with 👍 / 👎.
| if stale_reasons.is_empty() { | ||
| (HookState::Installed, None) |
There was a problem hiding this comment.
Verify the wrapper invokes this phase
When a managed wrapper for one phase is left at another hook path, for example copying the generated pre-push wrapper to .git/hooks/pre-commit, the marker/config/executable checks leave stale_reasons empty and this branch reports Installed. Git would then run the pre-push commands during pre-commit, so status should also validate the expected run {phase} invocation before declaring the hook current.
Useful? React with 👍 / 👎.
Summary
git smee status [--json]hook coverage and drift reportingFixes #144
Test plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-targets --all-featuresSummary by CodeRabbit
New Features
git smee statussubcommand to report hook coverage, detect drift, and identify obsolete hooks--jsonflag for stable JSON output compatible with tooling and automationDocumentation
statusanddoctorsubcommands, including example output