Skip to content

refactor(dev-tools): consolidate git hook scripts under contrib/dev-tools/git#1704

Merged
josecelano merged 2 commits intotorrust:developfrom
josecelano:refactor/consolidate-dev-scripts
Apr 22, 2026
Merged

refactor(dev-tools): consolidate git hook scripts under contrib/dev-tools/git#1704
josecelano merged 2 commits intotorrust:developfrom
josecelano:refactor/consolidate-dev-scripts

Conversation

@josecelano
Copy link
Copy Markdown
Member

Summary

Consolidates the duplicate/misplaced scripts from scripts/ into their canonical location under contrib/dev-tools/git/.

Changes

Files moved / deleted

  • scripts/install-git-hooks.shcontrib/dev-tools/git/install-git-hooks.sh
  • scripts/pre-commit.shdeleted (duplicate; canonical version now lives in hooks dir)

Scripts rewritten in new structured style

Both hook scripts now use a STEPS array with per-step timing and clear PASSED/FAILED output, matching the style of the new pre-commit.sh.

contrib/dev-tools/git/hooks/pre-commit.sh (fast, ~3 min):

  1. cargo machete — unused dependency check
  2. linter all — all linters
  3. cargo test --doc --workspace — documentation tests
  4. cargo test --tests --benches --examples --workspace --all-targets --all-features — all tests

Nightly toolchain checks and e2e tests are intentionally excluded — they are too slow for pre-commit and are covered by CI and pre-push.

contrib/dev-tools/git/hooks/pre-push.sh (comprehensive, ~15 min):

  1. cargo machete
  2. linter all
  3. cargo +nightly fmt --check
  4. cargo +nightly check …
  5. cargo +nightly doc …
  6. cargo test --doc --workspace
  7. cargo test … --all-targets --all-features
  8. E2E tests (e2e_tests_runner)

References updated

All references to the old scripts/ paths have been updated across:

  • .githooks/pre-commit
  • AGENTS.md
  • .github/workflows/copilot-setup-steps.yml
  • .github/agents/committer.agent.md
  • .github/agents/implementer.agent.md
  • .github/skills/dev/git-workflow/commit-changes/SKILL.md
  • .github/skills/dev/git-workflow/run-pre-commit-checks/SKILL.md
  • .github/skills/dev/maintenance/setup-dev-environment/SKILL.md
  • .github/skills/dev/maintenance/update-dependencies/SKILL.md
  • docs/issues/1697-ai-agent-configuration.md

…ools/git

Move scripts/ content to canonical locations:
- scripts/install-git-hooks.sh → contrib/dev-tools/git/install-git-hooks.sh
- scripts/pre-commit.sh → deleted (duplicate)
- contrib/dev-tools/git/hooks/pre-commit.sh → rewritten in new structured style
- contrib/dev-tools/git/hooks/pre-push.sh → rewritten in new structured style

The new pre-commit.sh uses a STEPS array with per-step timing and
PASSED/FAILED output. It excludes nightly toolchain checks and e2e tests
(too slow for pre-commit; covered by CI and pre-push).

The new pre-push.sh follows the same structured style and retains all
checks from the old script including nightly fmt/check/doc and e2e tests.

Update all references across agents, skills, workflows, and documentation.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates git-hook related developer tooling by removing the old scripts/ entrypoints and standardizing on the canonical location under contrib/dev-tools/git/, while updating all internal documentation/workflow references accordingly.

Changes:

  • Delete the duplicate scripts/pre-commit.sh and migrate callers to contrib/dev-tools/git/hooks/pre-commit.sh.
  • Move/standardize the hook installer to contrib/dev-tools/git/install-git-hooks.sh.
  • Rewrite pre-commit.sh and pre-push.sh hook scripts into a structured “timed steps” format, and update docs/skills/agents/workflows to reference the new paths.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/pre-commit.sh Removes the legacy/duplicate pre-commit entrypoint.
contrib/dev-tools/git/install-git-hooks.sh Canonical git hook installer path and updated usage comment.
contrib/dev-tools/git/hooks/pre-commit.sh Canonical structured pre-commit hook script.
contrib/dev-tools/git/hooks/pre-push.sh Canonical structured pre-push hook script (nightly + e2e).
.githooks/pre-commit Updates wrapper to call canonical pre-commit script under contrib/.
AGENTS.md Updates hook/script paths in repo guidance.
docs/issues/1697-ai-agent-configuration.md Updates referenced hook install + pre-commit invocation paths.
.github/workflows/copilot-setup-steps.yml Updates workflow path filters and install command to new locations.
.github/agents/committer.agent.md Updates “pre-commit validation command” path.
.github/agents/implementer.agent.md Updates “pre-commit validation command” path.
.github/skills/dev/git-workflow/commit-changes/SKILL.md Updates hook installation and pre-commit command references.
.github/skills/dev/git-workflow/run-pre-commit-checks/SKILL.md Updates hook installation and pre-commit command references.
.github/skills/dev/maintenance/setup-dev-environment/SKILL.md Updates hook installation and pre-commit command references.
.github/skills/dev/maintenance/update-dependencies/SKILL.md Updates verification command reference to canonical pre-commit script.
Comments suppressed due to low confidence (1)

contrib/dev-tools/git/install-git-hooks.sh:8

  • This installer copies hook wrappers from .githooks/ into .git/hooks/, but the repo currently only contains .githooks/pre-commit. As a result, the canonical contrib/dev-tools/git/hooks/pre-push.sh script will not be installed as a Git pre-push hook and won’t run automatically. Consider adding a .githooks/pre-push wrapper (like .githooks/pre-commit) or otherwise wiring pre-push into the installation process.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AGENTS.md Outdated
Comment thread contrib/dev-tools/git/hooks/pre-push.sh Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.43%. Comparing base (4b8a21f) to head (b3d1e6b).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1704   +/-   ##
========================================
  Coverage    86.43%   86.43%           
========================================
  Files          288      288           
  Lines        22672    22672           
  Branches     22672    22672           
========================================
+ Hits         19596    19597    +1     
  Misses        2838     2838           
+ Partials       238      237    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- AGENTS.md: clarify nightly toolchain is also needed for pre-push checks
- pre-push.sh: explicitly use cargo +stable for non-nightly steps to
  ensure consistent results across machines regardless of default toolchain
@josecelano
Copy link
Copy Markdown
Member Author

ACK b3d1e6b

@josecelano josecelano merged commit d51ef29 into torrust:develop Apr 22, 2026
22 checks passed
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.

2 participants