Add basic git commit date counter
This commit is contained in:
parent
6bdcb02a93
commit
798c1d937a
|
@ -0,0 +1,2 @@
|
||||||
|
__pycache__
|
||||||
|
.venv
|
|
@ -0,0 +1,3 @@
|
||||||
|
pandas
|
||||||
|
numpy
|
||||||
|
GitPython
|
|
@ -0,0 +1,25 @@
|
||||||
|
"""
|
||||||
|
Generate a CSV file with daily stats commit count from a set of repositories
|
||||||
|
"""
|
||||||
|
|
||||||
|
from git import Repo
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
REPO = "."
|
||||||
|
|
||||||
|
repo = Repo(REPO)
|
||||||
|
|
||||||
|
def repo_daily_commits(repo: Repo, year: int):
|
||||||
|
"""Count how many commit was performed for each days in the year"""
|
||||||
|
data = {}
|
||||||
|
for commit in repo.iter_commits(all=True):
|
||||||
|
timestamp = commit.authored_date
|
||||||
|
date = datetime.date.fromtimestamp(timestamp)
|
||||||
|
if int(date.year) != year:
|
||||||
|
continue
|
||||||
|
if date not in data:
|
||||||
|
data[date] = 0
|
||||||
|
data[date] += 1
|
||||||
|
return data
|
||||||
|
|
||||||
|
print(repo_daily_commits(repo, 2023))
|
Loading…
Reference in New Issue