-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·106 lines (92 loc) · 2.94 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python3
import calendar
import datetime
import os
import sys
from git import Repo
from loguru import logger
from pydriller import Repository
import tabulate
TABLEFMT = "github"
REPOSITORIES = {
"osism/ansible-collection-commons",
"osism/ansible-collection-services",
"osism/ansible-collection-validations",
"osism/ansible-playbooks",
"osism/ansible-playbooks-manager",
"osism/cfg-cookiecutter",
"osism/cfg-generics",
"osism/ci-image",
"osism/cloud-in-a-box",
"osism/container-image-ceph-ansible",
"osism/container-image-inventory-reconciler",
"osism/container-image-kolla-ansible",
"osism/container-image-osism-ansible",
"osism/container-images",
"osism/container-images-kolla",
"osism/deb-packaging",
"osism/defaults",
"osism/k8s-capi-images",
"osism/kolla-operations",
"osism/node-image",
"osism/openstack-flavor-manager",
"osism/openstack-image-manager",
"osism/openstack-octavia-amphora-image",
"osism/openstack-project-manager",
"osism/openstack-resource-manager",
"osism/openstack-sandbox-manager",
"osism/openstack-simple-stress",
"osism/openstack-themes",
"osism/osism.github.io",
"osism/python-osism",
"osism/release",
"osism/sbom",
"osism/terraform-base",
"osism/testbed",
"osism/tests",
}
AUTHORS = ["Christian Berendt"]
YEAR = 2024
MONTH = 1
level = "INFO"
log_fmt = (
"<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{level: <8}</level> | "
"<level>{message}</level>"
)
logger.remove()
logger.add(sys.stderr, format=log_fmt, level=level, colorize=True)
num_days = calendar.monthrange(YEAR, MONTH)[1]
days = [datetime.datetime(YEAR, MONTH, day) for day in range(1, num_days + 1)]
for repository in REPOSITORIES:
try:
Repo.clone_from(f"https://github.com/{repository}.git", f"cache/{repository}")
logger.info(f"Cloning {repository}")
except:
r = Repo(f"repositories/{repository}")
r.remotes.origin.pull()
logger.info(f"Pulling {repository}")
data = []
for day in days:
logger.info(f"Processing {day}")
data.append([day.strftime("%Y-%m-%d"), "", ""])
for repository in REPOSITORIES:
commits = Repository(
f"cache/{repository}",
only_in_branch="main",
since=day,
to=day.replace(hour=23, minute=59, second=59),
only_no_merge=True,
only_authors=AUTHORS,
).traverse_commits()
for commit in commits:
message = commit.msg.partition("\n")[0]
print(f"{message}, https://github.com/{repository}/commit/{commit.hash}")
data.append(
[
"",
commit.msg.partition("\n")[0],
f"https://github.com/{repository}/commit/{commit.hash}",
]
)
result = tabulate.tabulate(data, headers=["Date", "Title", "URL"], tablefmt=TABLEFMT)
print(result)