Skip to content

Commit

Permalink
Merge pull request #52 from JoshLabs/master
Browse files Browse the repository at this point in the history
Correct index.lock file deletion and other fixes & formatting
  • Loading branch information
sebdah authored Sep 27, 2016
2 parents 4c08927 + 83e4b58 commit b2db938
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 0 additions & 5 deletions git-pylint-commit-hook
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ LICENSE:
"""

import argparse
import os
import sys

from git_pylint_commit_hook import commit_hook
Expand Down Expand Up @@ -71,10 +70,6 @@ def main():
print('git-pylint-commit-hook version {}'.format(VERSION))
sys.exit(0)

# Remove the index.lock when it's exists
if os.path.exists('.git/index.lock'):
os.remove('.git/index.lock')

return commit_hook.check_repo(
args.limit,
args.pylint,
Expand Down
16 changes: 9 additions & 7 deletions git_pylint_commit_hook/commit_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _is_ignored(filename, ignored_paths):

def check_repo(
limit, pylint='pylint', pylintrc=None, pylint_params='',
suppress_report=False, always_show_violations=False, ignored_files=[]):
suppress_report=False, always_show_violations=False, ignored_files=None):
""" Main function doing the checks
:type limit: float
Expand All @@ -188,23 +188,27 @@ def check_repo(
:type ignored_files: list
:param ignored_files: List of files to exclude from the validation
"""
# Lists are mutable and should not be assigned in function arguments
if ignored_files is None:
ignored_files = []

# List of checked files and their results
python_files = []

# Set the exit code
all_filed_passed = True

if pylintrc is None:
# If no config is found, use the old default '.pylintrc'
pylintrc = pylint_config.find_pylintrc() or '.pylintrc'
# If no config is found, use the old default '.pylintrc'
pylintrc = pylint_config.find_pylintrc() or '.pylintrc'

# Stash any unstaged changes while we look at the tree
with _stash_unstaged():
# Find Python files
for filename in _get_list_of_committed_files():
try:
if _is_python_file(filename) and \
not _is_ignored(filename, ignored_files):
not _is_ignored(filename, ignored_files):
python_files.append((filename, None))
except IOError:
print('File not found (probably deleted): {}\t\tSKIPPED'.format(
Expand Down Expand Up @@ -266,9 +270,7 @@ def check_repo(
# Verify the score
score = _parse_score(out)
ignored = _check_ignore(out)
if ignored:
status = 'PASSED'
elif score >= float(limit):
if ignored or score >= float(limit):
status = 'PASSED'
else:
status = 'FAILED'
Expand Down

0 comments on commit b2db938

Please sign in to comment.