1818 'commit id' ,
1919 'branch' ,
2020)
21+ GOOGLE_MAX_CELL_LEN = 50000
22+
2123
2224
2325def log_repository_commits (
2426 client : IRepositoryAPI , repository : Repository , csv_name , start , finish , branch
2527):
28+
29+
30+ def log_commit_to_csv (info , csv_name ):
31+ with open (csv_name , 'a' , newline = '' ) as file :
32+ writer = csv .DictWriter (file , fieldnames = FIELDNAMES )
33+ writer .writerow (info )
34+
35+
36+ def log_commit_to_stdout (info ):
37+ print (info )
38+
39+
40+ def log_repository_commits (repository : Repository , csv_name , start , finish , branch ):
2641 branches = []
2742 match branch :
2843 case 'all' :
@@ -42,16 +57,11 @@ def log_repository_commits(
4257 or commit .date .astimezone (pytz .timezone (TIMEZONE )) > finish
4358 ):
4459 continue
45- commit_data = [
46- repository .name ,
47- commit .author .username ,
48- commit .author .email or EMPTY_FIELD ,
49- commit .date ,
50- '; ' .join ([file for file in commit .files ]),
51- commit ._id ,
52- branch ,
53- ]
54- info = dict (zip (FIELDNAMES , commit_data ))
60+ if commit .commit is not None :
61+ nvl = lambda val : val or EMPTY_FIELD
62+ commit_data = [repository .full_name , commit .commit .author .name , nvl (commit .author .login ), nvl (commit .commit .author .email ),
63+ commit .commit .author .date , '; ' .join ([file .filename for file in commit .files ]), commit .commit .sha , branch ]
64+ info = dict (zip (FIELDNAMES , commit_data ))
5565
5666 logger .log_to_csv (csv_name , FIELDNAMES , info )
5767 logger .log_to_stdout (info )
0 commit comments