Update gitlint configuration 58/106158/1
authorSangwook Ha <sangwook.ha@verizon.com>
Thu, 25 May 2023 21:11:30 +0000 (14:11 -0700)
committerSangwook Ha <sangwook.ha@verizon.com>
Thu, 25 May 2023 21:26:54 +0000 (14:26 -0700)
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 <sangwook.ha@verizon.com>
.pre-commit-config.yaml
tox.ini

index 4e69cef54266cf2cceafe838b102ad00dceed845..d688a1e9ee0791367d57841a30b95068b42572fe 100644 (file)
@@ -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 3f6f9e273b20285db7b46e6c694c9c087874c46d..bf2cee0cf53b480b3c097b055310b1a938983d68 100644 (file)
--- 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