Skip to content

Commit 04c3077

Browse files
f
1 parent 352615e commit 04c3077

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

commits_parser.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,9 @@
2121
GOOGLE_MAX_CELL_LEN = 50000
2222

2323

24-
2524
def log_repository_commits(
2625
client: IRepositoryAPI, repository: Repository, csv_name, start, finish, branch
2726
):
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):
4127
branches = []
4228
match branch:
4329
case 'all':
@@ -57,11 +43,18 @@ def log_repository_commits(repository: Repository, csv_name, start, finish, bran
5743
or commit.date.astimezone(pytz.timezone(TIMEZONE)) > finish
5844
):
5945
continue
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))
46+
47+
changed_files = '; '.join([file for file in commit.files])
48+
commit_data = [
49+
repository.name,
50+
commit.author.username,
51+
commit.author.email or EMPTY_FIELD,
52+
commit.date,
53+
changed_files[:GOOGLE_MAX_CELL_LEN],
54+
commit._id,
55+
branch,
56+
]
57+
info = dict(zip(FIELDNAMES, commit_data))
6558

6659
logger.log_to_csv(csv_name, FIELDNAMES, info)
6760
logger.log_to_stdout(info)

0 commit comments

Comments
 (0)