|
|
@@ -7,6 +7,11 @@ import os
|
|
7
|
7
|
import re
|
|
8
|
8
|
import sys
|
|
9
|
9
|
|
|
|
10
|
+def getoutput(cmd):
|
|
|
11
|
+ print '>> %s' % cmd
|
|
|
12
|
+ output = commands.getoutput(cmd)
|
|
|
13
|
+ return output
|
|
|
14
|
+
|
|
10
|
15
|
class DataCollector:
|
|
11
|
16
|
def __init__(self):
|
|
12
|
17
|
pass
|
|
|
@@ -17,7 +22,7 @@ class DataCollector:
|
|
17
|
22
|
self.dir = dir
|
|
18
|
23
|
|
|
19
|
24
|
##
|
|
20
|
|
- # TODO: get a dictionary of author
|
|
|
25
|
+ # : get a dictionary of author
|
|
21
|
26
|
def getAuthorInfo(self, author):
|
|
22
|
27
|
return None
|
|
23
|
28
|
|
|
|
@@ -32,6 +37,9 @@ class DataCollector:
|
|
32
|
37
|
def getLastCommitDate(self):
|
|
33
|
38
|
return datetime.datetime.now()
|
|
34
|
39
|
|
|
|
40
|
+ def getTags(self):
|
|
|
41
|
+ return []
|
|
|
42
|
+
|
|
35
|
43
|
def getTotalAuthors(self):
|
|
36
|
44
|
return -1
|
|
37
|
45
|
|
|
|
@@ -48,18 +56,18 @@ class GitDataCollector(DataCollector):
|
|
48
|
56
|
def collect(self, dir):
|
|
49
|
57
|
DataCollector.collect(self, dir)
|
|
50
|
58
|
|
|
51
|
|
- self.total_authors = int(commands.getoutput('git-log |git-shortlog -s |wc -l'))
|
|
52
|
|
- self.total_commits = int(commands.getoutput('git-rev-list --all |wc -l'))
|
|
53
|
|
- self.total_files = int(commands.getoutput('git-ls-files |wc -l'))
|
|
54
|
|
- self.total_lines = int(commands.getoutput('git-ls-files |xargs cat |wc -l'))
|
|
|
59
|
+ self.total_authors = int(getoutput('git-log |git-shortlog -s |wc -l'))
|
|
|
60
|
+ self.total_commits = int(getoutput('git-rev-list --all |wc -l'))
|
|
|
61
|
+ self.total_files = int(getoutput('git-ls-files |wc -l'))
|
|
|
62
|
+ self.total_lines = int(getoutput('git-ls-files |xargs cat |wc -l'))
|
|
55
|
63
|
|
|
56
|
64
|
def getAuthorInfo(self, author):
|
|
57
|
|
- commits = int(commands.getoutput('git-rev-list --all --author="%s" |wc -l' % author))
|
|
|
65
|
+ commits = int(getoutput('git-rev-list --all --author="%s" |wc -l' % author))
|
|
58
|
66
|
commits_frac = (100 * float(commits)) / self.getTotalCommits()
|
|
59
|
67
|
date_first = '0000-00-00'
|
|
60
|
68
|
date_last = '0000-00-00'
|
|
61
|
|
- rev_last = commands.getoutput('git-rev-list --all --author="%s" -n 1' % author)
|
|
62
|
|
- rev_first = commands.getoutput('git-rev-list --all --author="%s" |tail -n 1' % author)
|
|
|
69
|
+ rev_last = getoutput('git-rev-list --all --author="%s" -n 1' % author)
|
|
|
70
|
+ rev_first = getoutput('git-rev-list --all --author="%s" |tail -n 1' % author)
|
|
63
|
71
|
date_first = self.revToDate(rev_first)
|
|
64
|
72
|
date_last = self.revToDate(rev_last)
|
|
65
|
73
|
|
|
|
@@ -67,9 +75,16 @@ class GitDataCollector(DataCollector):
|
|
67
|
75
|
return res
|
|
68
|
76
|
|
|
69
|
77
|
def getAuthors(self):
|
|
70
|
|
- lines = commands.getoutput('git-rev-list --all --pretty=format:%an |grep -v ^commit |sort |uniq')
|
|
|
78
|
+ lines = getoutput('git-rev-list --all --pretty=format:%an |grep -v ^commit |sort |uniq')
|
|
|
79
|
+ return lines.split('\n')
|
|
|
80
|
+
|
|
|
81
|
+ def getTags(self):
|
|
|
82
|
+ lines = getoutput('git-show-ref --tags |cut -d/ -f3')
|
|
71
|
83
|
return lines.split('\n')
|
|
72
|
84
|
|
|
|
85
|
+ def getTagDate(self, tag):
|
|
|
86
|
+ return self.revToDate('tags/' + tag)
|
|
|
87
|
+
|
|
73
|
88
|
def getTotalAuthors(self):
|
|
74
|
89
|
return self.total_authors
|
|
75
|
90
|
|
|
|
@@ -83,7 +98,7 @@ class GitDataCollector(DataCollector):
|
|
83
|
98
|
return self.total_lines
|
|
84
|
99
|
|
|
85
|
100
|
def revToDate(self, rev):
|
|
86
|
|
- stamp = int(commands.getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev))
|
|
|
101
|
+ stamp = int(getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev))
|
|
87
|
102
|
return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d')
|
|
88
|
103
|
|
|
89
|
104
|
class ReportCreator:
|
|
|
@@ -102,6 +117,7 @@ class HTMLReportCreator(ReportCreator):
|
|
102
|
117
|
f.write("""<html>
|
|
103
|
118
|
<head>
|
|
104
|
119
|
<title>StatGit</title>
|
|
|
120
|
+ <link rel="stylesheet" href="statgit.css" type="text/css" />
|
|
105
|
121
|
</head>
|
|
106
|
122
|
<body>
|
|
107
|
123
|
""")
|
|
|
@@ -118,6 +134,13 @@ class HTMLReportCreator(ReportCreator):
|
|
118
|
134
|
f.write('<dt>Authors</dt><dd>%s</dd>' % data.getTotalAuthors())
|
|
119
|
135
|
f.write('</dl>');
|
|
120
|
136
|
|
|
|
137
|
+ f.write("""<ul>
|
|
|
138
|
+<li><a href="activity.html">Activity</a></li>
|
|
|
139
|
+<li><a href="authors.html">Authors</a></li>
|
|
|
140
|
+<li><a href="files.html">Files</a></li>
|
|
|
141
|
+</ul>
|
|
|
142
|
+""")
|
|
|
143
|
+
|
|
121
|
144
|
f.write('<h2>Authors</h2>')
|
|
122
|
145
|
|
|
123
|
146
|
f.write('<table class="authors">')
|
|
|
@@ -128,10 +151,10 @@ class HTMLReportCreator(ReportCreator):
|
|
128
|
151
|
f.write('</table>')
|
|
129
|
152
|
|
|
130
|
153
|
f.write('<h2>Tags</h2>')
|
|
131
|
|
-
|
|
132
|
154
|
f.write('<table>')
|
|
133
|
155
|
f.write('<tr><th>Name</th><th>Date</th><th>Developers</th></tr>')
|
|
134
|
|
-
|
|
|
156
|
+ for tag in data.getTags():
|
|
|
157
|
+ f.write('<tr><td>%s</td><td></td></tr>' % tag)
|
|
135
|
158
|
f.write('</table>')
|
|
136
|
159
|
|
|
137
|
160
|
f.write('</body>\n</html>');
|