diff --git a/git-pylint-commit-hook b/git-pylint-commit-hook index 6b06fdd..3058f58 100755 --- a/git-pylint-commit-hook +++ b/git-pylint-commit-hook @@ -12,7 +12,7 @@ LICENSE: http://www.apache.org/licenses/LICENSE-2.0.html """ -VERSION = '2.1.2' +VERSION = '2.1.3' import argparse import sys diff --git a/git_pylint_commit_hook/commit_hook.py b/git_pylint_commit_hook/commit_hook.py index b65923d..7b1e475 100644 --- a/git_pylint_commit_hook/commit_hook.py +++ b/git_pylint_commit_hook/commit_hook.py @@ -79,6 +79,13 @@ def _is_python_file(filename): return 'python' in first_line and '#!' in first_line +def _is_ignored(filename, ignore_pattern_text_list): + for ignore_pattern_text in ignore_pattern_text_list: + if re.findall(ignore_pattern_text, filename): + return True + return False + + _SCORE_REGEXP = re.compile( r'^Your\ code\ has\ been\ rated\ at\ (\-?[0-9\.]+)/10') @@ -157,10 +164,18 @@ def check_repo( # Stash any unstaged changes while we look at the tree with _stash_unstaged(): + + # Ignore files + params = pylint_params.split() + ignore_pattern_text_list = [] + for param in params: + if 'ignore' in param: + ignore_pattern_text_list.extend(param.split('=')[1].split(',')) + # Find Python files for filename in _get_list_of_committed_files(): try: - if _is_python_file(filename): + if _is_python_file(filename) and not _is_ignored(filename, ignore_pattern_text_list): python_files.append((filename, None)) except IOError: print('File not found (probably deleted): {}\t\tSKIPPED'.format( diff --git a/git_pylint_commit_hook/settings.conf b/git_pylint_commit_hook/settings.conf index 0efa5df..6e8aec9 100644 --- a/git_pylint_commit_hook/settings.conf +++ b/git_pylint_commit_hook/settings.conf @@ -1,2 +1,2 @@ [general] -version: 2.1.2 +version: 2.1.3 diff --git a/setup.py b/setup.py index a344122..9fa191f 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='git-pylint-commit-hook', - version='2.1.2', + version='2.1.3', license='Apache License, Version 2.0', description='Git commit hook that checks Python files with pylint', author='Sebastian Dahlgren',