Skip to content

Commit 352615e

Browse files
HadronColliderthehighestmath
authored andcommitted
issue #67 max len for changed_files (max cell len error in googleapi)
1 parent 001b407 commit 352615e

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

commits_parser.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,26 @@
1818
'commit id',
1919
'branch',
2020
)
21+
GOOGLE_MAX_CELL_LEN = 50000
22+
2123

2224

2325
def 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

Comments
 (0)