feat(pre-commit): 配置 Pre-commit Hooks,实现本地 commit 前自动 lint/format 守护#187
Merged
Conversation
…mat 及通用代码卫生检查; - 新建 .pre-commit-config.yaml:使用 local hook(language: system + uv run)调用 uv.lock 锁定的 Ruff, 确保本地 hooks 与 CI 流水线使用完全一致的版本(Single Source of Truth); 并集成 pre-commit-hooks 通用卫生检查(trailing-whitespace、end-of-file-fixer、check-yaml 等) - pyproject.toml:dev 依赖组追加 pre-commit>=4.0 - uv.lock:同步锁定 pre-commit==4.5.1 及其依赖 - AGENTS.md:卓越运营规范追加第 5 条 Pre-commit Hooks 安装与使用说明 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
当前项目仅在 GitHub Actions CI 中执行
ruff check/ruff format --check,lint/format 问题只能在推送后被 CI 发现,浪费 CI 资源与反馈时间。变更内容
核心设计
采用
pre-commit框架 +localhook(language: system + uv run) 方案,而非astral-sh/ruff-pre-commit远程镜像仓库,理由如下:uv.lock唯一管控,消除版本漂移的 Split-Brain 风险.github/workflows/ci.yml完全一致uv文件变更
.pre-commit-config.yamlpyproject.tomlpre-commit>=4.0uv.lockpre-commit==4.5.1及依赖AGENTS.mdpre-commit install安装说明Hooks 清单
验证结果
安装说明(新贡献者)
🤖 Generated with Claude Code, CodeX, Gemini
Co-Authored-By: Aurelius Huangthreefish.ai@gmail.com