Migrate git hooks scripts from Bash to Rust

未关闭
#1,843 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
冷清
技术栈
bash, rust
领域
cli, tooling

调研方向

Start with the three scripts named in the issue: contrib/dev-tools/git/hooks/pre-commit.sh, contrib/dev-tools/git/hooks/pre-push.sh, and contrib/dev-tools/git/install-git-hooks.sh, then read the full implementation spec under docs/issues/open/ and the referenced CLI output contract ADR. Compare the current checks and installation behavior with the Phase 1 requirements; done means the Rust binary replaces the scripts and complies with the stated NDJSON-on-stderr and exit-code contract, with Phase 2 enhancements treated separately.

由索引模型根据 Issue 内容生成。

描述

Goal

Replace the three Bash scripts that implement pre-commit checks, pre-push checks, and git hook installation with a single Rust binary that improves testability, type safety, and maintainability, and that adds real-time feedback during long-running checks so developers and automation agents can see hook progress without cancelling valid runs.

Scripts to replace

Script Purpose
contrib/dev-tools/git/hooks/pre-commit.sh Runs fast quality checks (cargo machete --with-metadata, linter, doc tests)
contrib/dev-tools/git/hooks/pre-push.sh Runs comprehensive checks (machete, linters, nightly build, tests, E2E)
contrib/dev-tools/git/install-git-hooks.sh Installs hooks from .githooks/ to .git/hooks/

Motivation

The scripts have grown beyond simple orchestration (engineering policy #3 in AGENTS.md). They now implement structured argument parsing, a multi-step runner with timing and log management, and two output modes — logic that is duplicated across both scripts. This also creates feedback UX and redundant-execution problems:

  • Hooks appear hung during long checks (pre-push takes ~15 min); no intermediate progress is visible.
  • If only Markdown files are staged, the full Rust suite still runs unnecessarily.
  • Hooks re-run even when they already passed for the same set of changes.

Implementation plan (two phases)

Phase 1 — Core migration: implement the same steps as the current scripts using NDJSON output (no --format=text|json switch), switch over, and remove the Bash scripts.

Phase 2 — Enhancements: heartbeat events for long steps, smart step skipping for docs-only commits, and idempotency cache to skip hooks that already passed for the same changes.

Full spec

See docs/issues/open/ for the complete implementation spec once the spec-only PR is merged.

Compliance

The new binary must comply with the global CLI output contract ADR (docs/adrs/20260519000000_define_global_cli_output_contract.md) from day one: no-stdout-result class, NDJSON on stderr, exit codes 0/1/2.

主要语言
Rust
星标
532
派生
56
平均合并
11 小时 20 分钟
30 天内合并 PR
282

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

torrust/torrust-tracker 的其他 Issue

查看 torrust/torrust-tracker 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。