diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f7550b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +.venv diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bdd037a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +pandas +numpy +GitPython \ No newline at end of file diff --git a/src/gitstats/commits.py b/src/gitstats/commits.py new file mode 100644 index 0000000..e812192 --- /dev/null +++ b/src/gitstats/commits.py @@ -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)) \ No newline at end of file