7
7
import logging
8
8
import os
9
9
import re
10
- from dataclasses import dataclass
11
10
import shlex
12
11
import warnings
13
12
from gitdb .db .loose import LooseObjectDB
@@ -902,21 +901,7 @@ class InfoTD(TypedDict, total=False):
902
901
committer_email : str
903
902
committer_date : int
904
903
905
- @dataclass
906
- class InfoDC (Dict [str , Union [str , int ]]):
907
- sha : str = ''
908
- id : str = ''
909
- filename : str = ''
910
- summary : str = ''
911
- author : str = ''
912
- author_email : str = ''
913
- author_date : int = 0
914
- committer : str = ''
915
- committer_email : str = ''
916
- committer_date : int = 0
917
-
918
- # info: InfoTD = {}
919
- info = InfoDC ()
904
+ info : InfoTD = {}
920
905
921
906
keepends = True
922
907
for line_bytes in data .splitlines (keepends ):
@@ -943,10 +928,10 @@ class InfoDC(Dict[str, Union[str, int]]):
943
928
# another line of blame with the same data
944
929
digits = parts [- 1 ].split (" " )
945
930
if len (digits ) == 3 :
946
- info . id = firstpart
931
+ info = { 'id' : firstpart }
947
932
blames .append ([None , []])
948
- elif info . id != firstpart :
949
- info . id = firstpart
933
+ elif info [ 'id' ] != firstpart :
934
+ info = { 'id' : firstpart }
950
935
blames .append ([commits .get (firstpart ), []])
951
936
# END blame data initialization
952
937
else :
@@ -962,12 +947,20 @@ class InfoDC(Dict[str, Union[str, int]]):
962
947
# committer-time 1192271832
963
948
# committer-tz -0700 - IGNORED BY US
964
949
role = m .group (0 )
965
- if firstpart .endswith ('-mail' ):
966
- info [f"{ role } _email" ] = parts [- 1 ]
967
- elif firstpart .endswith ('-time' ):
968
- info [f"{ role } _date" ] = int (parts [- 1 ])
969
- elif role == firstpart :
970
- info [role ] = parts [- 1 ]
950
+ if role == 'author' :
951
+ if firstpart .endswith ('-mail' ):
952
+ info ["author_email" ] = parts [- 1 ]
953
+ elif firstpart .endswith ('-time' ):
954
+ info ["author_date" ] = int (parts [- 1 ])
955
+ elif role == firstpart :
956
+ info ["author" ] = parts [- 1 ]
957
+ elif role == 'committer' :
958
+ if firstpart .endswith ('-mail' ):
959
+ info ["committer_email" ] = parts [- 1 ]
960
+ elif firstpart .endswith ('-time' ):
961
+ info ["committer_date" ] = int (parts [- 1 ])
962
+ elif role == firstpart :
963
+ info ["committer" ] = parts [- 1 ]
971
964
# END distinguish mail,time,name
972
965
else :
973
966
# handle
@@ -980,34 +973,33 @@ class InfoDC(Dict[str, Union[str, int]]):
980
973
info ['summary' ] = parts [- 1 ]
981
974
elif firstpart == '' :
982
975
if info :
983
- sha = info . id
976
+ sha = info [ 'id' ]
984
977
c = commits .get (sha )
985
978
if c is None :
986
979
c = Commit (self , hex_to_bin (sha ),
987
- author = Actor ._from_string (info . author + ' ' + info . author_email ),
988
- authored_date = info . author_date ,
980
+ author = Actor ._from_string (info [ ' author' ] + ' ' + info [ ' author_email' ] ),
981
+ authored_date = info [ ' author_date' ] ,
989
982
committer = Actor ._from_string (
990
- info . committer + ' ' + info . committer_email ),
991
- committed_date = info . committer_date )
983
+ info [ ' committer' ] + ' ' + info [ ' committer_email' ] ),
984
+ committed_date = info [ ' committer_date' ] )
992
985
commits [sha ] = c
993
986
blames [- 1 ][0 ] = c
994
987
# END if commit objects needs initial creation
995
- if not is_binary :
996
- if line_str and line_str [0 ] == '\t ' :
997
- line_str = line_str [1 :]
998
- line_AnyStr : str | bytes = line_str
999
- else :
1000
- line_AnyStr = line_bytes
1001
- # NOTE: We are actually parsing lines out of binary data, which can lead to the
1002
- # binary being split up along the newline separator. We will append this to the
1003
- # blame we are currently looking at, even though it should be concatenated with
1004
- # the last line we have seen.
1005
-
1006
- # end handle line contents
1007
988
if blames [- 1 ][1 ] is not None :
1008
- blames [- 1 ][1 ].append (line_AnyStr )
989
+ if not is_binary :
990
+ if line_str and line_str [0 ] == '\t ' :
991
+ line_str = line_str [1 :]
992
+
993
+ blames [- 1 ][1 ].append (line_str )
994
+ else :
995
+ # NOTE: We are actually parsing lines out of binary data, which can lead to the
996
+ # binary being split up along the newline separator. We will append this to the
997
+ # blame we are currently looking at, even though it should be concatenated with
998
+ # the last line we have seen.
999
+ blames [- 1 ][1 ].append (line_bytes )
1000
+ # end handle line contents
1009
1001
1010
- info . id = sha
1002
+ info = { 'id' : sha }
1011
1003
# END if we collected commit info
1012
1004
# END distinguish filename,summary,rest
1013
1005
# END distinguish author|committer vs filename,summary,rest
0 commit comments