Commit e07658ed authored by Gustavo Padovan's avatar Gustavo Padovan
Browse files

stats: read git log from stdin

parent 046db88f
#! /usr/bin/env python #! /usr/bin/env python
from pygit2 import Repository, Tag from pygit2 import Repository, Tag
from pygit2 import GIT_SORT_TOPOLOGICAL from pygit2 import GIT_SORT_TOPOLOGICAL
import sys
import csv
import re import re
details=True details=True
...@@ -65,16 +67,8 @@ def print_commits(dict): ...@@ -65,16 +67,8 @@ def print_commits(dict):
if __name__ == "__main__": if __name__ == "__main__":
repo = Repository(GIT_TREE) repo = Repository(GIT_TREE)
for line in csv.reader(sys.stdin, delimiter=','):
first_commit = repo.revparse_single('v3.12') commit = repo.get(line[0])
if isinstance(first_commit, Tag):
first_commit = first_commit.get_object()
last_commit = repo.revparse_single('HEAD')
if isinstance(last_commit, Tag):
last_commit = last_commit.get_object()
for commit in repo.walk(last_commit.id, GIT_SORT_TOPOLOGICAL):
if EMAIL_PATTERN in commit.author.email: if EMAIL_PATTERN in commit.author.email:
add_contributor(contributors, commit.author.email, commit.author.name) add_contributor(contributors, commit.author.email, commit.author.name)
add_commit(authored, commit.author.email, commit) add_commit(authored, commit.author.email, commit)
...@@ -95,9 +89,6 @@ if __name__ == "__main__": ...@@ -95,9 +89,6 @@ if __name__ == "__main__":
for m in match: for m in match:
add_contributor(contributors, m[1], m[0]) add_contributor(contributors, m[1], m[0])
add_commit(tag[1], m[1], commit) add_commit(tag[1], m[1], commit)
if commit.id == first_commit.id:
break
print("# Authored (%d)\n" % total_commits(authored)) print("# Authored (%d)\n" % total_commits(authored))
print_commits(authored) print_commits(authored)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment