git-linter/bin/pre-commit

42 lines
955 B
Python
Executable File

#!/usr/bin/env python
from git_lint.git_lint import load_config, run_linters, git_base
from git_lint.reporters import print_report
import gettext
_ = gettext.gettext
def main(*args):
if git_base is None:
sys.exit(_('A git repository was not found.'))
pre_commit_options = {
'staging': True,
'base': True
}
config = load_config(pre_commit_options, git_base)
(results,
unlintable_filenames,
cant_lint_filenames,
broken_linter_names,
unfindable_filenames) = run_linters(pre_commit_options, config)
print_report(results,
unlintable_filenames,
cant_lint_filenames,
broken_linter_names,
unfindable_filenames,
pre_commit_options)
if not len(results):
return 0
return max([i[2] for i in results if len(i)])
if __name__ == '__main__':
import sys
sys.exit(main(*sys.argv))