From 11080265c59d786fc09fa383fe174b89736279f8 Mon Sep 17 00:00:00 2001 From: Mystic <215104920@qq.com> Date: Tue, 19 Mar 2024 14:11:24 +0800 Subject: [PATCH] feat: introduce pre-commit for all templates --- template/cxx/.pre-commit-config.yml | 15 +++++++++++++++ template/cxx/CONTRIBUTING.md | 2 +- template/go/.pre-commit-config.yml | 19 +++++++++++++++++++ template/go/CONTRIBUTING.md | 2 +- template/py/.pre-commit-config.yml | 23 +++++++++++++++++++++++ template/py/CONTRIBUTING.md | 2 +- 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 template/cxx/.pre-commit-config.yml create mode 100644 template/go/.pre-commit-config.yml create mode 100644 template/py/.pre-commit-config.yml diff --git a/template/cxx/.pre-commit-config.yml b/template/cxx/.pre-commit-config.yml new file mode 100644 index 0000000..66618e6 --- /dev/null +++ b/template/cxx/.pre-commit-config.yml @@ -0,0 +1,15 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + args: [ --fix=lf ] + - id: trailing-whitespace + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.18.4 + hooks: + - id: commitizen diff --git a/template/cxx/CONTRIBUTING.md b/template/cxx/CONTRIBUTING.md index a1d2475..4476dcf 100644 --- a/template/cxx/CONTRIBUTING.md +++ b/template/cxx/CONTRIBUTING.md @@ -19,7 +19,7 @@ Try to do one pull request per change. ### Updating the changelog Update the changes you have made in -[CHANGELOG](https://github.com/{{gh_uname}}/{{project-name}}/blob/main/CHANGELOG.md) +[CHANGELOG](CHANGELOG.md) file under the **Unreleased** section. Add the changes of your pull request to one of the following subsections, diff --git a/template/go/.pre-commit-config.yml b/template/go/.pre-commit-config.yml new file mode 100644 index 0000000..7e8d1ca --- /dev/null +++ b/template/go/.pre-commit-config.yml @@ -0,0 +1,19 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + args: [ --fix=lf ] + - id: trailing-whitespace + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.18.4 + hooks: + - id: commitizen + - repo: https://github.com/golangci/golangci-lint + rev: v1.56.2 + hooks: + - id: golangci-lint diff --git a/template/go/CONTRIBUTING.md b/template/go/CONTRIBUTING.md index 919e7ff..5d235e5 100644 --- a/template/go/CONTRIBUTING.md +++ b/template/go/CONTRIBUTING.md @@ -19,7 +19,7 @@ Try to do one pull request per change. ### Updating the changelog Update the changes you have made in -[CHANGELOG](https://github.com/{{gh_uname}}/{{project-name}}/blob/main/CHANGELOG.md) +[CHANGELOG](CHANGELOG.md) file under the **Unreleased** section. Add the changes of your pull request to one of the following subsections, diff --git a/template/py/.pre-commit-config.yml b/template/py/.pre-commit-config.yml new file mode 100644 index 0000000..2b6813b --- /dev/null +++ b/template/py/.pre-commit-config.yml @@ -0,0 +1,23 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + args: [ --fix=lf ] + - id: trailing-whitespace + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.18.4 + hooks: + - id: commitizen + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.3 + hooks: + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format diff --git a/template/py/CONTRIBUTING.md b/template/py/CONTRIBUTING.md index befb3db..fa25a24 100644 --- a/template/py/CONTRIBUTING.md +++ b/template/py/CONTRIBUTING.md @@ -19,7 +19,7 @@ Try to do one pull request per change. ### Updating the changelog Update the changes you have made in -[CHANGELOG](https://github.com/{{gh_uname}}/{{project-name}}/blob/main/CHANGELOG.md) +[CHANGELOG](CHANGELOG.md) file under the **Unreleased** section. Add the changes of your pull request to one of the following subsections,