From 3cf11f453191d1ce183aa94c79b2471b06ddaa09 Mon Sep 17 00:00:00 2001 From: Oliver Olsen <103891157+oliversen@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:30:46 +0300 Subject: [PATCH] chore: add `pre-commit` framework to automatically check code before committing --- .gitlint | 9 +++++++++ .pre-commit-config.yaml | 34 ++++++++++++++++++++++++++++++++++ requirements-dev.txt | 3 ++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .gitlint create mode 100644 .pre-commit-config.yaml diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..713df77 --- /dev/null +++ b/.gitlint @@ -0,0 +1,9 @@ +[general] +contrib = contrib-title-conventional-commits +ignore = body-is-missing + +[contrib-title-conventional-commits] +types = fix,feat,chore,docs,style,refactor,perf,test,revert,ci,build + +[title-max-length] +line-length = 120 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..86a88f2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +default_install_hook_types: + - pre-commit + - commit-msg + +default_stages: + - pre-commit + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: no-commit-to-branch + - repo: https://github.com/jorisroovers/gitlint + rev: v0.19.1 + hooks: + - id: gitlint + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + additional_dependencies: + - flake8-pyproject + - flake8-import-order + - flake8-builtins + - flake8-annotations + - flake8-quotes + - flake8-simplify + - flake8-bugbear + - repo: http://github.com/psf/black + rev: 24.4.2 + hooks: + - id: black + args: [--check] \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 8cc2bf8..555a208 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,5 @@ flake8-quotes==3.4.0 flake8-simplify==0.21.0 flake8-bugbear==24.4.26 isort==5.13.2 -black==24.4.1 \ No newline at end of file +black==24.4.1 +pre-commit==3.7.0 \ No newline at end of file