Skip to content

fix: resolve hooks trust mechanism issues#101

Merged
avihut merged 16 commits intomasterfrom
daft-86/hooks-fix
Jan 27, 2026
Merged

fix: resolve hooks trust mechanism issues#101
avihut merged 16 commits intomasterfrom
daft-86/hooks-fix

Conversation

@avihut
Copy link
Owner

@avihut avihut commented Jan 27, 2026

Summary

  • Fix trust database timestamp calculation and display
  • Add reset-trust command to clear all trust settings
  • Add pager support for hooks list output
  • Add config migration framework using version-migrate crate
  • Add colored output to all hooks commands for better visual hierarchy
  • Rename untrust command to deny for consistency with trust levels
  • Various UX improvements (compact output mode, smart path resolution, separate prompt command)

Changes

Trust Database

  • Store timestamps as Unix epoch (i64) instead of ISO strings
  • Automatic migration from v1 (string timestamps) to v2 (epoch timestamps)
  • Fix timestamp calculation that was showing future dates

New Commands

  • hooks reset-trust - Clear all trust settings with confirmation
  • hooks prompt - Separate command for conditional trust (replaces trust --prompt)

UX Improvements

  • Add -s/--short flag for compact status output
  • Add colored output: green (allow), yellow (prompt), red (deny)
  • Hook names and commands shown in cyan
  • Path labels shown in dim gray
  • Smart relative path resolution in suggested commands
  • Pager support for long repository lists

Breaking Changes

  • Renamed hooks untrust to hooks deny
  • Changed -y/--yes flag to -f/--force

Test plan

  • Unit tests pass (cargo test --lib)
  • Clippy passes with no warnings
  • Code formatting verified
  • Manual testing of hooks commands

🤖 Generated with Claude Code

avihut and others added 16 commits January 27, 2026 23:21
- Fix path canonicalization in get_git_common_dir() to ensure consistent
  trust lookups across worktrees (core bug fix for issue #86)
- Add path argument to trust, untrust, and status commands (default: .)
- Show project root instead of .git directory in output
- Improve help text with styled trust levels matching clap's formatting
- Remove unnecessary file size display from hook listings
- Make status output more concise with "PATH (type)" format
- Add styles module to isolate ANSI escape codes from application code
- Clarify that trust applies to all worktrees in success messages

Fixes #86

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Standardize confirmation skip flags across all commands:
- hooks trust/untrust: -y --yes → -f --force
- branch move: -y --yes → -f --force
- multi-remote enable/disable: -y --yes → -f --force
- setup: merge --yes and --force into single -f --force flag

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add new `git daft hooks prompt` command for prompt-level trust
- Remove --prompt flag from trust command
- Update status output to show prompt command instead of trust --prompt
- Rename cmd_trust to cmd_set_trust with TrustLevel parameter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
release-plz was comparing against stale crates.io version (0.1.5)
instead of git tags (v1.0.7), causing it to skip PR creation when
local version exceeded registry version.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…atus

- Add relative_path helper to compute shortest path between directories
- Show "." when inside the repo (works from any worktree or subdirectory)
- Show relative path only when running status from outside the repo

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds a short format option to `git daft hooks status` that displays
a compact three-line summary: path (type), repository (if different),
and hooks list with trust level.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reduces verbose trust change output to match short status format:
- PATH (repository)
- HOOKS LIST (TRUST LEVEL)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds `git daft hooks reset-trust` command that clears all repository
trust entries and patterns from the trust database.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Uses pager (respects $PAGER, defaults to less) when output exceeds
20 lines and stdout is a terminal.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Converts ISO 8601 timestamps (2026-02-08T07:28:54Z) to a more
readable format (2026-02-08 07:28) in hooks list output.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The previous implementation used naive date math that didn't account
for leap years or varying month lengths, producing incorrect dates.
Now uses Howard Hinnant's date algorithm for accurate conversion.

Note: Existing trust entries have incorrect timestamps and will need
to be re-trusted to get correct dates.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Store granted_at as Unix epoch (i64) instead of formatted string
- Use chrono crate for proper local time formatting
- Strip .git suffix from paths in list output
- Remove manual date calculation code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add automatic migration from V1 (string timestamps) to V2 (epoch timestamps)
for the trust database. Uses version-migrate crate for type-safe migrations.

- Create versioned DTOs in trust_dto.rs with MigratesTo and IntoDomain traits
- Detect actual schema version by examining granted_at field type
- Handle mislabeled V2 databases that have version=1 but epoch timestamps
- Auto-save migrated files to persist the upgrade
- Update default version from 1 to 2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add color styling to hooks command output for better visual hierarchy:
- Trust levels: green (allow), yellow (prompt), red (deny)
- Path type labels in dim gray
- Section headers in bold
- Commands and hook names in cyan

Also adds colored formatting to help text for all hooks subcommands.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename the subcommand from 'untrust' to 'deny' for consistency
with the trust level naming (deny, prompt, allow).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@avihut avihut linked an issue Jan 27, 2026 that may be closed by this pull request
@avihut avihut added bug Something isn't working enhancement New feature or request labels Jan 27, 2026
@avihut avihut self-assigned this Jan 27, 2026
@avihut avihut merged commit 95c8407 into master Jan 27, 2026
4 checks passed
@avihut avihut deleted the daft-86/hooks-fix branch January 27, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hooks trust mechanism usage unclear

1 participant