Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/git_commit_guard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ def check_imperative(desc, result):
first = tokens[0]
if first in IMPERATIVE_VERBS:
return
tagged = nltk.pos_tag(tokens)
if tagged[0][1] != "VB":
tagged = nltk.pos_tag(["i", *tokens])
if tagged[1][1] not in {"VB", "VBP"}:
result.error(
f"expected imperative verb, got '{tagged[0][0]}' (POS={tagged[0][1]})",
f"expected imperative verb, got '{tagged[1][0]}' (POS={tagged[1][1]})",
)


Expand Down
5 changes: 5 additions & 0 deletions tests/test_git_commit_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ def test_non_whitelist_imperative_passes(self):
check_imperative("refactor authentication module", r)
assert r.ok

def test_write_imperative_passes(self):
r = Result()
check_imperative("write unit tests", r)
assert r.ok

def test_empty_desc_passes(self):
r = Result()
check_imperative("", r)
Expand Down