mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Update migrate_config.py
Added if statement to prevent looping through header lines if configuration file is empty
This commit is contained in:
parent
35a78c06d0
commit
7b491c7110
1 changed files with 4 additions and 2 deletions
|
|
@ -21,8 +21,10 @@ def _migrate_map(contents):
|
||||||
# Find the first non-header line
|
# Find the first non-header line
|
||||||
lines = contents.splitlines(True)
|
lines = contents.splitlines(True)
|
||||||
i = 0
|
i = 0
|
||||||
while _is_header_line(lines[i]):
|
# Only loop on non empty configuration file
|
||||||
i += 1
|
if i < len(lines):
|
||||||
|
while _is_header_line(lines[i]):
|
||||||
|
i += 1
|
||||||
|
|
||||||
header = ''.join(lines[:i])
|
header = ''.join(lines[:i])
|
||||||
rest = ''.join(lines[i:])
|
rest = ''.join(lines[i:])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue