|
|
@@ -73,6 +73,9 @@ class GitDataCollector(DataCollector):
|
|
73
|
73
|
self.activity_by_hour_of_day = {} # hour -> commits
|
|
74
|
74
|
self.activity_by_day_of_week = {} # day -> commits
|
|
75
|
75
|
|
|
|
76
|
+ # TODO
|
|
|
77
|
+ self.authors = {} # name -> {commits, first_commit_stamp, last_commit_stamp}
|
|
|
78
|
+
|
|
76
|
79
|
# activity
|
|
77
|
80
|
lines = getoutput('git-rev-list HEAD --pretty=format:%at |grep -v ^commit').split('\n')
|
|
78
|
81
|
for stamp in lines:
|
|
|
@@ -105,10 +108,24 @@ class GitDataCollector(DataCollector):
|
|
105
|
108
|
stamp = int(parts[0])
|
|
106
|
109
|
author = ' '.join(parts[1:])
|
|
107
|
110
|
|
|
|
111
|
+ # First and last commit stamp
|
|
108
|
112
|
if self.last_commit_stamp == 0:
|
|
109
|
113
|
self.last_commit_stamp = stamp
|
|
110
|
114
|
self.first_commit_stamp = stamp
|
|
111
|
115
|
|
|
|
116
|
+ # author stats
|
|
|
117
|
+ if author not in self.authors:
|
|
|
118
|
+ self.authors[author] = {}
|
|
|
119
|
+ # TODO commits
|
|
|
120
|
+ if 'last_commit_stamp' not in self.authors[author]:
|
|
|
121
|
+ self.authors[author]['last_commit_stamp'] = stamp
|
|
|
122
|
+ self.authors[author]['first_commit_stamp'] = stamp
|
|
|
123
|
+ if 'commits' in self.authors[author]:
|
|
|
124
|
+ self.authors[author]['commits'] += 1
|
|
|
125
|
+ else:
|
|
|
126
|
+ self.authors[author]['commits'] = 1
|
|
|
127
|
+
|
|
|
128
|
+ # author of the month/year
|
|
112
|
129
|
yymm = datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m')
|
|
113
|
130
|
if yymm in self.author_of_month:
|
|
114
|
131
|
if author in self.author_of_month[yymm]:
|
|
|
@@ -140,14 +157,12 @@ class GitDataCollector(DataCollector):
|
|
140
|
157
|
return self.activity_by_hour_of_day
|
|
141
|
158
|
|
|
142
|
159
|
def getAuthorInfo(self, author):
|
|
143
|
|
- commits = int(getoutput('git-rev-list HEAD --author="%s" |wc -l' % author))
|
|
|
160
|
+ a = self.authors[author]
|
|
|
161
|
+
|
|
|
162
|
+ commits = a['commits']
|
|
144
|
163
|
commits_frac = (100 * float(commits)) / self.getTotalCommits()
|
|
145
|
|
- date_first = '0000-00-00'
|
|
146
|
|
- date_last = '0000-00-00'
|
|
147
|
|
- rev_last = getoutput('git-rev-list --all --author="%s" -n 1' % author)
|
|
148
|
|
- rev_first = getoutput('git-rev-list --all --author="%s" |tail -n 1' % author)
|
|
149
|
|
- date_first = self.revToDate(rev_first)
|
|
150
|
|
- date_last = self.revToDate(rev_last)
|
|
|
164
|
+ date_first = datetime.datetime.fromtimestamp(a['first_commit_stamp']).strftime('%Y-%m-%d')
|
|
|
165
|
+ date_last = datetime.datetime.fromtimestamp(a['last_commit_stamp']).strftime('%Y-%m-%d')
|
|
151
|
166
|
|
|
152
|
167
|
res = { 'commits': commits, 'commits_frac': commits_frac, 'date_first': date_first, 'date_last': date_last }
|
|
153
|
168
|
return res
|