From d1aaadfceb50ddb592d1ef0afaa8ac416280ea5f Mon Sep 17 00:00:00 2001 From: Sangwook Ha Date: Thu, 25 May 2023 14:11:30 -0700 Subject: [PATCH] Update gitlint configuration Update pre-commit configuration for gitlint to add gitlint-ci, a hook for CI verification, and use it during tox verification. Create separate testenvs for installation/uninstallation/update of pre-commit hook scripts. And also add a testenv for gitlint to run the command with tox. Change-Id: I3842539a7ec8d2851ff1b48c2633d964017c70cf Signed-off-by: Sangwook Ha --- .pre-commit-config.yaml | 7 +++++-- tox.ini | 30 ++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4e69cef542..d688a1e9ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,9 +25,12 @@ repos: additional_dependencies: ['robotframework'] - repo: https://github.com/jorisroovers/gitlint - rev: v0.17.0 + rev: v0.19.1 hooks: - - id: gitlint + - id: gitlint + stages: [commit-msg] + - id: gitlint-ci + stages: [manual] - repo: local hooks: diff --git a/tox.ini b/tox.ini index 3f6f9e273b..bf2cee0cf5 100644 --- a/tox.ini +++ b/tox.ini @@ -10,10 +10,36 @@ deps = -rdocs/requirements.txt commands = sphinx-build -W -n -b html -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/html -[testenv:pre-commit] +[testenv:pre-commit-install] basepython = python3 deps = pre-commit commands = + pre-commit install pre-commit install --hook-type commit-msg + +[testenv:pre-commit-uninstall] +basepython = python3 +deps = pre-commit +commands = + pre-commit uninstall + pre-commit uninstall --hook-type commit-msg + +[testenv:pre-commit-autoupdate] +basepython = python3 +deps = pre-commit +commands = + pre-commit autoupdate + +[testenv:pre-commit] +basepython = python3 +deps = pre-commit +passenv = HOME +commands = pre-commit run --all-files --show-diff-on-failure - pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG + pre-commit run gitlint-ci --hook-stage manual + +[testenv:gitlint] +basepython = python3 +deps = gitlint +commands = + gitlint -- 2.36.6