From 7b491c7110a2e2234ca19ff8b8d66f7efb1422fe Mon Sep 17 00:00:00 2001 From: Jesse Bona <37656694+jessebona@users.noreply.github.com> Date: Fri, 1 Feb 2019 19:15:59 +1100 Subject: [PATCH] Update migrate_config.py Added if statement to prevent looping through header lines if configuration file is empty --- pre_commit/commands/migrate_config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pre_commit/commands/migrate_config.py b/pre_commit/commands/migrate_config.py index 3f73bb83..47bb7695 100644 --- a/pre_commit/commands/migrate_config.py +++ b/pre_commit/commands/migrate_config.py @@ -21,8 +21,10 @@ def _migrate_map(contents): # Find the first non-header line lines = contents.splitlines(True) i = 0 - while _is_header_line(lines[i]): - i += 1 + # Only loop on non empty configuration file + if i < len(lines): + while _is_header_line(lines[i]): + i += 1 header = ''.join(lines[:i]) rest = ''.join(lines[i:])