-
Notifications
You must be signed in to change notification settings - Fork 111
Closed
Description
If gitlint is run without --staged, then the author name is always None and there is no guard for that situation in the ignore-by-author-name rule. Here is a setup to reproduce it:
$ gitlint --version
gitlint, version 0.18.0
$ cat .git/hooks/commit-msg
#!/bin/bash
gitlint --msg-filename $1
$ cat .gitlint
[ignore-by-author-name]
regex=(.*)dependabot(.*)
$ git commit
hint: Waiting for your editor to close the file... Waiting for Emacs...
WARNING: I4 - ignore-by-author-name: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-by-author-name.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
Traceback (most recent call last):
File "/home/adam/.local/bin/gitlint", line 8, in <module>
sys.exit(cli())
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/click/core.py", line 1635, in invoke
rv = super().invoke(ctx)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/gitlint/cli.py", line 313, in cli
ctx.invoke(lint)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/gitlint/cli.py", line 363, in lint
violations = linter.lint(commit)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/gitlint/lint.py", line 94, in lint
rule.apply(self.config, commit)
File "/home/adam/.local/pipx/venvs/gitlint-core/lib/python3.10/site-packages/gitlint/rules.py", line 479, in apply
if regex_method(commit.author_name):
TypeError: expected string or bytes-like object
$The fix should be very simple, just adding a None check to the offending line so it is if commit.author_name is not None and regex_method(commit.author_name):, although maybe a warning should be printed since if gitlint is run without --staged the ignore-by-author-name rule will never be able to indicate that the rule should be ignored.
Metadata
Metadata
Assignees
Labels
bugUser-facing bugsUser-facing bugs
Projects
Status
0.19.0