From a684e894ac9fade7e42d88127e5e40f191f5b59d Mon Sep 17 00:00:00 2001 From: James Walmsley Date: Mon, 8 Feb 2021 19:53:35 +0000 Subject: [PATCH] Fix bug when processing diff with multiple renames. --- tests/samples/git_rename.diff | 14 ++++++++++++++ tests/test_parser.py | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/samples/git_rename.diff b/tests/samples/git_rename.diff index 6a28228..a51f4d3 100644 --- a/tests/samples/git_rename.diff +++ b/tests/samples/git_rename.diff @@ -11,3 +11,17 @@ index a071991..4dbab21 100644 Some content -Some content +Some modified content + +diff --git a/oldfile b/newfile +similarity index 85% +rename from oldfile +rename to newfile +index a071991..4dbab21 100644 +--- a/oldfile ++++ b/newfile +@@ -9,4 +9,4 @@ Some content + Some content + Some content + Some content +-Some content ++Some modified content diff --git a/tests/test_parser.py b/tests/test_parser.py index 841c1c1..7d8ebdb 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -411,13 +411,13 @@ def test_git_renaming(self): with codecs.open(file_path, 'r', encoding='utf-8') as diff_file: res = PatchSet(diff_file) - self.assertEqual(len(res), 1) + self.assertEqual(len(res), 2) patch = res[0] self.assertTrue(patch.is_rename) self.assertEqual(patch.added, 1) self.assertEqual(patch.removed, 1) - self.assertEqual(len(res.modified_files), 1) + self.assertEqual(len(res.modified_files), 2) self.assertEqual(len(res.added_files), 0) self.assertEqual(len(res.removed_files), 0)