Created
October 25, 2012 16:08
-
-
Save alexwright/3953706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_commit_activity(self, project): | |
from datetime import date, timedelta | |
from pygit2 import Repository | |
from pygit2 import GIT_SORT_TIME | |
repo = Repository(project.gitrepo) | |
weeks = self.get_weeks() | |
for commit in repo.walk(repo.head.oid, GIT_SORT_TIME): | |
commit_time = date.fromtimestamp(commit.commit_time) | |
commit_week = commit_time - timedelta(days=commit_time.weekday()) | |
if commit_week not in weeks: | |
continue | |
weeks[commit_week]['mine'] += 1 | |
counts = [] | |
max = 0 | |
for k in sorted(weeks.iterkeys()): | |
counts.append({ | |
"week": k.isoformat(), | |
"mine": weeks[k]['mine'], | |
"others": weeks[k]['others'], | |
}) | |
return counts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment