git-linter/bin/pre-commit

42 lines
955 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env python
from git_lint.git_lint import load_config, run_linters, git_base
from git_lint.reporters import print_report
2016-09-30 01:36:27 +00:00
import gettext
_ = gettext.gettext
def main(*args):
2016-09-29 19:38:23 +00:00
if git_base is None:
sys.exit(_('A git repository was not found.'))
2016-09-30 01:36:27 +00:00
pre_commit_options = {
'staging': True,
2016-09-29 19:38:23 +00:00
'base': True
}
2016-09-30 01:36:27 +00:00
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)
2016-09-30 01:36:27 +00:00
print_report(results,
unlintable_filenames,
cant_lint_filenames,
broken_linter_names,
unfindable_filenames,
pre_commit_options)
2016-09-30 01:36:27 +00:00
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))