From 52796e95cfa662995b16f966d632b30373c00de5 Mon Sep 17 00:00:00 2001 From: "Pocze Bence (XC-DX/ESP2-Bp)" Date: Thu, 14 Sep 2023 15:46:29 +0200 Subject: [PATCH] handle if only a rename happened and no diff block is returned --- pydiffchecker/line_shift_checker.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pydiffchecker/line_shift_checker.py b/pydiffchecker/line_shift_checker.py index f3a65ef..913a2c7 100644 --- a/pydiffchecker/line_shift_checker.py +++ b/pydiffchecker/line_shift_checker.py @@ -61,6 +61,12 @@ class LineShiftChecker: shifted_lines[f'{file_info["src"]}:{old_start}'] = None old_start += 1 + if not diff_started: + # it was a pure rename, so no diff blocks were returned, + # we just put the lines into the dict + shifted_lines = {f'{file_info["src"]}:{i}': f'{file_info["dst"]}:{i}' + for i in range(0, lines_in_source_file)} + assert lines_in_source_file == len(shifted_lines) return shifted_lines