mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 13:06:53 +00:00
added a mercurial hook
This commit is contained in:
parent
ed429af48c
commit
8fbf4c0a81
2 changed files with 40 additions and 0 deletions
|
|
@ -109,3 +109,25 @@ def main():
|
|||
warnings += check(stdin, '<stdin>')
|
||||
|
||||
raise SystemExit(warnings > 0)
|
||||
|
||||
def hg_hook(ui, repo, **kwargs):
|
||||
pep8.process_options()
|
||||
warnings = 0
|
||||
files = []
|
||||
for rev in xrange(repo[kwargs['node']], len(repo)):
|
||||
for file_ in repo[rev].files():
|
||||
if file_ not in files:
|
||||
files.append(file_)
|
||||
|
||||
for file_ in files:
|
||||
warnings += checkPath(file_)
|
||||
warnings += pep8.input_file(file_)
|
||||
|
||||
strict = ui.config('flake8', 'strict')
|
||||
if strict is None:
|
||||
strict = True
|
||||
|
||||
if strict.lower() in ('1', 'true'):
|
||||
return warnings
|
||||
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue