Fix: local calls to pre-commit tox profile 18/67818/8
authorGuillaume Lambert <guillaume.lambert@orange.com>
Wed, 26 May 2021 18:56:25 +0000 (20:56 +0200)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Sun, 30 May 2021 07:19:49 +0000 (07:19 +0000)
When run locally, pre-commit tox profile resulted in the following
failure:
$ tox -e pre-commit
[..]
gitlint...........................................................Failed
- hook id: gitlint
- exit code: 254

An error occurred while executing \
'/usr/bin/git config --get user.name': b''

The reason behind is that tox virtualenv cannot directly access the
$HOME shell variable to retrieve the local git configuration unless
this variable is explicitly declared accessible via the passenv tox
parameter.
This is required by gitlint to retrieve the correct git configuration
parameters.

Signed-off-by: Guillaume Lambert <guillaume.lambert@orange.com>
Change-Id: I99197f88cf4024a5922fe62ec07610921dcf515f

tox.ini

diff --git a/tox.ini b/tox.ini
index a1f2e6b..9664f40 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -41,6 +41,7 @@ commands =
 [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