Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7b491c7

Browse files
authored
Update migrate_config.py
Added if statement to prevent looping through header lines if configuration file is empty
1 parent 35a78c0 commit 7b491c7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pre_commit/commands/migrate_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ def _migrate_map(contents):
2121
# Find the first non-header line
2222
lines = contents.splitlines(True)
2323
i = 0
24-
while _is_header_line(lines[i]):
25-
i += 1
24+
# Only loop on non empty configuration file
25+
if i < len(lines):
26+
while _is_header_line(lines[i]):
27+
i += 1
2628

2729
header = ''.join(lines[:i])
2830
rest = ''.join(lines[i:])

0 commit comments

Comments
 (0)