From 480bd8b496c769d02c116ce9269066d7b2c58cfe Mon Sep 17 00:00:00 2001 From: Manu Raghavan Date: Wed, 10 Jun 2020 15:46:03 +0530 Subject: [PATCH] Print token, not match --- pre_commit_hooks/no_commit_keywords.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pre_commit_hooks/no_commit_keywords.py b/pre_commit_hooks/no_commit_keywords.py index b581a68..c59ea50 100644 --- a/pre_commit_hooks/no_commit_keywords.py +++ b/pre_commit_hooks/no_commit_keywords.py @@ -15,7 +15,8 @@ def check_for_no_commit_tokens( match = re.search(token, lines) if match: # no-commit token is present - return match.string + # return offending token + return token return None @@ -36,9 +37,9 @@ def main(argv: Optional[Sequence[str]] = None) -> int: for filename in args.filenames: _, extension = os.path.splitext(filename.lower()) - match_string = check_for_no_commit_tokens(filename, tokens) - if match_string: - print(f'Found no-commit token in {filename}: {match_string}') + token = check_for_no_commit_tokens(filename, tokens) + if token: + print(f'Found no-commit token in {filename}: {token}') return_code = 1 return return_code