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

Skip to content

Commit 4beda47

Browse files
committed
Fix change_type
For copy and rename we can have the score with the letter
1 parent 8f76463 commit 4beda47

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

git/diff.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,11 @@ def handle_diff_line(line):
471471

472472
meta, _, path = line[1:].partition('\t')
473473
old_mode, new_mode, a_blob_id, b_blob_id, change_type = meta.split(None, 4)
474+
# Change type can be R100
475+
# R: status letter
476+
# 100: score (in case of copy and rename)
477+
change_type = change_type[0]
478+
score = ''.join(change_type[1:]) or None
474479
path = path.strip()
475480
a_path = path.encode(defenc)
476481
b_path = path.encode(defenc)

git/test/test_diff.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def test_diff_with_rename(self):
108108
self.assertIsNotNone(diff.renamed)
109109
self.assertEqual(diff.rename_from, 'this')
110110
self.assertEqual(diff.rename_to, 'that')
111+
self.assertEqual(diff.change_type, 'R')
111112
self.assertEqual(len(list(diffs.iter_change_type('R'))), 1)
112113

113114
def test_diff_of_modified_files_not_added_to_the_index(self):

0 commit comments

Comments
 (0)