mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-10 14:54:17 +00:00
Merge branch 'bug/303' into 'master'
Do not run git-hook checks when there are no files Closes #303 See merge request !174
This commit is contained in:
commit
1a6b02cb96
1 changed files with 10 additions and 3 deletions
|
|
@ -45,10 +45,17 @@ def hook(lazy=False, strict=False):
|
||||||
app.initialize(['.'])
|
app.initialize(['.'])
|
||||||
app.options.exclude = update_excludes(app.options.exclude, tempdir)
|
app.options.exclude = update_excludes(app.options.exclude, tempdir)
|
||||||
app.options._running_from_vcs = True
|
app.options._running_from_vcs = True
|
||||||
app.run_checks(filepaths)
|
# Apparently there are times when there are no files to check (e.g.,
|
||||||
|
# when amending a commit). In those cases, let's not try to run checks
|
||||||
|
# against nothing.
|
||||||
|
if filepaths:
|
||||||
|
app.run_checks(filepaths)
|
||||||
|
|
||||||
|
# If there were files to check, update their paths and report the errors
|
||||||
|
if filepaths:
|
||||||
|
update_paths(app.file_checker_manager, tempdir)
|
||||||
|
app.report_errors()
|
||||||
|
|
||||||
update_paths(app.file_checker_manager, tempdir)
|
|
||||||
app.report_errors()
|
|
||||||
if strict:
|
if strict:
|
||||||
return app.result_count
|
return app.result_count
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue