diff --git a/backend/.pre-commit-config.yaml b/backend/.pre-commit-config.yaml new file mode 100644 index 0000000..bdbf3cd --- /dev/null +++ b/backend/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +# 后端 pre-commit hooks 配置 +# 安装方式:pip install pre-commit && pre-commit install +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + args: ['--maxkb=5000'] + - id: check-merge-conflict + - id: debug-statements + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.0 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/backend/requirements.txt b/backend/requirements.txt index d1c4527..6c4ae3a 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -30,4 +30,8 @@ Pillow==10.4.0 pyinstaller==6.9.0 dvadmin3-celery==3.1.6 oss2==2.19.1 -cos-python-sdk-v5==1.9.37 \ No newline at end of file +cos-python-sdk-v5==1.9.37 + +# Git hooks +pre-commit>=3.0.0 +ruff>=0.9.0 \ No newline at end of file