@@ -377,15 +377,25 @@ def stats(self) -> Stats:
377377 :return:
378378 :class:`Stats`
379379 """
380- if not self .parents :
381- text = self .repo .git .diff_tree (self .hexsha , "--" , numstat = True , no_renames = True , root = True )
382- text2 = ""
383- for line in text .splitlines ()[1 :]:
380+
381+ def process_lines (lines : List [str ]) -> str :
382+ text = ""
383+ for file_info , line in zip (lines , lines [len (lines ) // 2 :]):
384+ change_type = file_info .split ("\t " )[0 ][- 1 ]
384385 (insertions , deletions , filename ) = line .split ("\t " )
385- text2 += "%s\t %s\t %s\n " % (insertions , deletions , filename )
386- text = text2
386+ text += "%s\t %s\t %s\t %s\n " % (change_type , insertions , deletions , filename )
387+ return text
388+
389+ if not self .parents :
390+ lines = self .repo .git .diff_tree (
391+ self .hexsha , "--" , numstat = True , no_renames = True , root = True , raw = True
392+ ).splitlines ()[1 :]
393+ text = process_lines (lines )
387394 else :
388- text = self .repo .git .diff (self .parents [0 ].hexsha , self .hexsha , "--" , numstat = True , no_renames = True )
395+ lines = self .repo .git .diff (
396+ self .parents [0 ].hexsha , self .hexsha , "--" , numstat = True , no_renames = True , raw = True
397+ ).splitlines ()
398+ text = process_lines (lines )
389399 return Stats ._list_from_string (self .repo , text )
390400
391401 @property
0 commit comments