Skip to content

refactor(hooks): retire dev/scripts/git-hooks — crates is the single source#6

Merged
WomB0ComB0 merged 1 commit intomainfrom
refactor/retire-dev-hook-templates
Apr 14, 2026
Merged

refactor(hooks): retire dev/scripts/git-hooks — crates is the single source#6
WomB0ComB0 merged 1 commit intomainfrom
refactor/retire-dev-hook-templates

Conversation

@WomB0ComB0
Copy link
Copy Markdown
Member

@WomB0ComB0 WomB0ComB0 commented Apr 14, 2026

Summary

Phase 4 consolidation. The canonical hook templates now live only in resq-software/crates/crates/resq-cli/templates/git-hooks/. This repo used to ship a byte-identical copy under scripts/git-hooks/; it's retired.

scripts/install-hooks.sh — two-path install

  1. resq on PATHresq dev install-hooks (offline, uses embedded templates)
  2. No resqcurl from the crates master raw URL

RESQ_CRATES_REF replaces RESQ_DEV_REF for pinning the fallback.

Retired

  • scripts/git-hooks/{pre-commit,commit-msg,prepare-commit-msg,pre-push,post-checkout,post-merge,README.md}

tests/hooks/helpers.bash

Fetches templates from the crates raw URL once per bats session, cached under /tmp. RESQ_HOOK_SRC_DIR lets you point at a local template dir for pre-push testing. 33/33 bats tests still pass.

.github/workflows/hooks-sync.yml

  • Dropped the cross-repo diff-check (no copy to compare).
  • lint — shellcheck + bash-parse on the two installers.
  • smoke (new) — spins up a throwaway git repo, runs install-hooks.sh with scrubbed PATH to force the raw-fetch path, asserts 6 hooks present + executable + parse.

Docs

  • README: "three copies" claim replaced with the single-source story + the resq-preferred / raw-fallback sequence.
  • AGENTS: workspace tree reflects the retirement.

Test plan

  • shellcheck -S warning + bash -n green locally
  • Both install paths smoke-tested against a fresh tempdir
  • bats tests/hooks/ → 33/33 using the crates raw source
  • CI hooks-sync + hooks-tests green on this PR

Breaking change note

Any external tooling that raw-fetched from resq-software/dev/main/scripts/git-hooks/... needs to point at resq-software/crates/master/crates/resq-cli/templates/git-hooks/.... No sibling ResQ repo does this — they all install via install-hooks.sh.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated guides for git hook installation and distribution to reflect new deployment model.
  • Chores

    • Enhanced hook installation with intelligent fallback support for offline and network-based scenarios.
    • Improved validation through functional installation verification testing.
    • Reorganized hook template management and sourcing approach.

…urce

Phase 4 consolidation. Canonical hook content is now owned exclusively by
resq-software/crates (crates/resq-cli/templates/git-hooks/).

scripts/install-hooks.sh:
  - When `resq` is on PATH, delegate to `resq dev install-hooks` — the
    binary embeds the templates via include_str! so there's no network
    round-trip.
  - Otherwise fall back to curl against
    raw.githubusercontent.com/resq-software/crates/master/.../templates/git-hooks/
    (was: resq-software/dev/main/scripts/git-hooks/ — retired).
  - RESQ_CRATES_REF replaces RESQ_DEV_REF for pinning the fallback.

scripts/git-hooks/ — removed entirely (6 hook files + README.md).

tests/hooks/helpers.bash:
  - Fetch templates from the crates raw URL (once per bats session,
    cached under /tmp).
  - RESQ_HOOK_SRC_DIR lets you point at a local template dir for
    pre-push testing. 33/33 tests still pass.

.github/workflows/hooks-sync.yml — rewritten:
  - No more diff-check (nothing to diff against on this side).
  - `lint` job shellchecks install-hooks.sh + install-resq.sh.
  - New `smoke` job: spins up a throwaway git repo, runs the installer
    with a scrubbed PATH (forcing the raw-fetch fallback), and asserts
    the 6 hooks are present, executable, and parse.

README.md + AGENTS.md updated to reflect the single-source story and drop
the "three copies" note.

Verified:
  - shellcheck -S warning + bash -n clean
  - resq-preferred path: `resq dev install-hooks` scaffolds 6 hooks
  - raw-fetch fallback: curl from crates master installs 6 hooks
  - bats tests/hooks/: 33/33 pass (uses cached templates from crates raw)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This change migrates canonical git hook templates from scripts/git-hooks/ in this repository to the resq-software/crates repository. The installer script is updated to run resq dev install-hooks when available, falling back to downloading templates from crates via raw GitHub URL. All local hook scripts and related documentation are removed.

Changes

Cohort / File(s) Summary
CI Workflow and Hook Sync
.github/workflows/hooks-sync.yml
Updated path filters to trigger on scripts/install-resq.sh instead of scripts/git-hooks/**. Replaced drift-check job with smoke job that creates a test repo, runs install-hooks.sh in fallback mode, and verifies hook installation and core.hooksPath configuration.
Documentation Updates
AGENTS.md, README.md
Updated to reflect that canonical hook templates now live in resq-software/crates. Documented installer behavior: uses resq dev install-hooks when available, otherwise downloads from crates repo via curl. Clarified that installed hooks remain thin shims.
Removed Hook Scripts and Directory Docs
scripts/git-hooks/README.md, scripts/git-hooks/pre-commit, scripts/git-hooks/commit-msg, scripts/git-hooks/pre-push, scripts/git-hooks/prepare-commit-msg, scripts/git-hooks/post-checkout, scripts/git-hooks/post-merge
Entirely removed canonical hook implementations and directory documentation. Hooks now sourced from crates repository instead.
Installer Script
scripts/install-hooks.sh
Changed installation logic: prioritizes resq dev install-hooks when resq is available; otherwise downloads hook templates from crates repo URL. Renamed environment variable RESQ_DEV_REF to RESQ_CRATES_REF (default master). Updated fallback error message to reference scripts/install-resq.sh.
Test Infrastructure
tests/hooks/helpers.bash
Added _ensure_hook_cache() function to download and cache hook templates from crates repo on first run. Updated init_repo_with_hooks() to use cached hooks instead of local scripts/git-hooks/ directory. Introduced RESQ_HOOK_SRC_DIR and RESQ_HOOK_RAW_BASE environment variables for test customization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hops and commits, now living afar,
In the crates repository they are!
No local copies, just resq commands—
Distributed hooks make stronger Git-hands. 🌿✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: consolidating git hook templates to a single canonical source (crates) by retiring the duplicate copies in dev/scripts/git-hooks/.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/retire-dev-hook-templates

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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the git hook management system by removing local hook shims and delegating their installation to the resq CLI or a remote fetch from the resq-software/crates repository. Documentation and tests have been updated to reflect this change. Feedback includes a critical issue where the git configuration for hooksPath might be skipped during installation if the preferred path is taken, as well as several robustness concerns regarding the hook caching mechanism used in tests, such as weak cache validation and potential interference with local source overrides.

Comment thread scripts/install-hooks.sh
Comment on lines +67 to 68
git -C "$TARGET_ROOT" config core.hooksPath .git-hooks
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The git config core.hooksPath .git-hooks command was moved inside the else block. This means if the preferred path (using resq dev install-hooks) is taken, the repository's git configuration is not updated to point to the .git-hooks directory. Unless the resq binary is guaranteed to perform this configuration itself, the hooks will not be active after installation. It is safer to keep this configuration step outside the conditional block to ensure the repository is correctly configured regardless of how the hook files were placed.

Suggested change
git -C "$TARGET_ROOT" config core.hooksPath .git-hooks
fi
fi
git -C "$TARGET_ROOT" config core.hooksPath .git-hooks

Comment thread tests/hooks/helpers.bash
Comment on lines +15 to +21
_ensure_hook_cache() {
[ -d "$HOOK_SRC_CACHE" ] && [ -e "$HOOK_SRC_CACHE/pre-commit" ] && return 0
mkdir -p "$HOOK_SRC_CACHE"
for h in pre-commit commit-msg prepare-commit-msg pre-push post-checkout post-merge; do
curl -fsSL "$HOOK_RAW_BASE/$h" -o "$HOOK_SRC_CACHE/$h"
done
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _ensure_hook_cache function has a few robustness issues:

  1. Weak Cache Validation: The check [ -e "$HOOK_SRC_CACHE/pre-commit" ] only verifies the first hook. If the initial download is interrupted, subsequent test runs will skip the download but fail during the cp step in init_repo_with_hooks because other hooks are missing.
  2. Local Source Interference: If RESQ_HOOK_SRC_DIR is set to a local directory that happens to be missing pre-commit, the function will attempt to curl remote templates into that local directory, which is unexpected behavior for a source override.
  3. Shared Cache Path: Using a fixed path like /tmp/resq-canonical-hooks can lead to permission issues or race conditions on multi-user systems or shared CI runners. Consider using a user-specific path or a unique temporary directory.

@WomB0ComB0 WomB0ComB0 merged commit 98a9594 into main Apr 14, 2026
7 of 8 checks passed
@WomB0ComB0 WomB0ComB0 deleted the refactor/retire-dev-hook-templates branch April 14, 2026 17:51
WomB0ComB0 added a commit that referenced this pull request Apr 14, 2026
Two stragglers missed in #6:

1. scripts/install-hooks.ps1 still raw-fetched from
   resq-software/dev/$Ref/scripts/git-hooks — the retired path. Windows
   users following the curl-pipe flow would get 404s. Rewritten to
   mirror install-hooks.sh's two-path strategy: prefer
   `resq dev install-hooks` when on PATH, fall back to the crates raw
   URL. RESQ_CRATES_REF replaces RESQ_DEV_REF. Adds the scaffold prompt
   for the local-pre-push, matching the bash mirror.

2. .github/workflows/hooks-tests.yml had `paths: scripts/git-hooks/**`
   in its trigger filter — that directory no longer exists, so the
   workflow wouldn't fire on test changes alone. Trigger now fires on
   tests/hooks/**, scripts/install-hooks.sh, and the workflow file.
   Added a weekly cron so canonical-template drift on the crates side
   gets caught even without a dev-side change.

Verified end-to-end: install-resq.sh → fresh repo + Cargo.toml →
install-hooks.sh (resq-preferred path) → `git commit` triggers
`resq pre-commit` which runs through Copyright/Large Files/Debug/
Secrets/Audit/Format. Doctor reports healthy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
WomB0ComB0 added a commit that referenced this pull request Apr 14, 2026
Two stragglers missed in #6:

1. scripts/install-hooks.ps1 still raw-fetched from
   resq-software/dev/$Ref/scripts/git-hooks — the retired path. Windows
   users following the curl-pipe flow would get 404s. Rewritten to
   mirror install-hooks.sh's two-path strategy: prefer
   `resq dev install-hooks` when on PATH, fall back to the crates raw
   URL. RESQ_CRATES_REF replaces RESQ_DEV_REF. Adds the scaffold prompt
   for the local-pre-push, matching the bash mirror.

2. .github/workflows/hooks-tests.yml had `paths: scripts/git-hooks/**`
   in its trigger filter — that directory no longer exists, so the
   workflow wouldn't fire on test changes alone. Trigger now fires on
   tests/hooks/**, scripts/install-hooks.sh, and the workflow file.
   Added a weekly cron so canonical-template drift on the crates side
   gets caught even without a dev-side change.

Verified end-to-end: install-resq.sh → fresh repo + Cargo.toml →
install-hooks.sh (resq-preferred path) → `git commit` triggers
`resq pre-commit` which runs through Copyright/Large Files/Debug/
Secrets/Audit/Format. Doctor reports healthy.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
WomB0ComB0 added a commit to resq-software/crates that referenced this pull request Apr 14, 2026
- .github/workflows/hooks-sync.yml: drop `drift-check-dev` job. It
  fetched from resq-software/dev/main/scripts/git-hooks/ — which was
  retired in resq-software/dev#6 — so the job would fail every run.
  The remaining local drift-check between templates/ and .git-hooks/
  is now the whole check surface.

- AGENTS.md + CLAUDE.md: rewrite the Git hooks section to reflect the
  post-Phase-4 reality. This repo is the single source of truth; the
  old "will converge once resq dev install-hooks scaffolds from
  embedded templates" qualifier is obsolete (shipped in #48). The
  link to dev/tree/main/scripts/git-hooks no longer resolves;
  replaced with a forward link to the installer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
WomB0ComB0 added a commit to resq-software/crates that referenced this pull request Apr 14, 2026
…58)

- .github/workflows/hooks-sync.yml: drop `drift-check-dev` job. It
  fetched from resq-software/dev/main/scripts/git-hooks/ — which was
  retired in resq-software/dev#6 — so the job would fail every run.
  The remaining local drift-check between templates/ and .git-hooks/
  is now the whole check surface.

- AGENTS.md + CLAUDE.md: rewrite the Git hooks section to reflect the
  post-Phase-4 reality. This repo is the single source of truth; the
  old "will converge once resq dev install-hooks scaffolds from
  embedded templates" qualifier is obsolete (shipped in #48). The
  link to dev/tree/main/scripts/git-hooks no longer resolves;
  replaced with a forward link to the installer.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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