-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
first_non_ascii_commit.py
45 lines (34 loc) · 1.29 KB
/
first_non_ascii_commit.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
"""
Find first and total commits with non-ASCII messages and authors
"""
from __future__ import annotations
import time
from git import Repo # pip install GitPython
def print_info(commit: str) -> None:
# print(commit)
print(commit.author)
print(commit.message)
print(time.asctime(time.gmtime(commit.committed_date)))
print(f"https://github.com/python/cpython/commit/{commit}")
print()
def main() -> None:
repo = Repo("~/github/cpython")
non_ascii_commit_messages = non_ascii_authors = 0
authors = set()
for commit in repo.iter_commits("main", reverse=True):
if not commit.message.isascii():
if not non_ascii_commit_messages:
print("First non-ASCII commit message:\n")
print_info(commit)
non_ascii_commit_messages += 1
if not commit.author.name.isascii():
if not non_ascii_authors:
print("First non-ASCII commit author:\n")
print_info(commit)
authors.add(commit.author.name)
non_ascii_authors += 1
print("Total non-ASCII commit messages:", non_ascii_commit_messages)
print("Total non-ASCII commit authors:", non_ascii_authors)
print("Unique non-ASCII commit authors:", len(authors))
if __name__ == "__main__":
main()