|
|
@@ -11,6 +11,8 @@ class DataCollector:
|
|
11
|
11
|
def __init__(self):
|
|
12
|
12
|
pass
|
|
13
|
13
|
|
|
|
14
|
+ ##
|
|
|
15
|
+ # This should be the main function to extract data from the repository.
|
|
14
|
16
|
def collect(self, dir):
|
|
15
|
17
|
self.dir = dir
|
|
16
|
18
|
|
|
|
@@ -45,6 +47,11 @@ class DataCollector:
|
|
45
|
47
|
class GitDataCollector(DataCollector):
|
|
46
|
48
|
def collect(self, dir):
|
|
47
|
49
|
DataCollector.collect(self, dir)
|
|
|
50
|
+
|
|
|
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'))
|
|
48
|
55
|
|
|
49
|
56
|
def getAuthorInfo(self, author):
|
|
50
|
57
|
commits = int(commands.getoutput('git-rev-list --all --author="%s" |wc -l' % author))
|
|
|
@@ -53,10 +60,8 @@ class GitDataCollector(DataCollector):
|
|
53
|
60
|
date_last = '0000-00-00'
|
|
54
|
61
|
rev_last = commands.getoutput('git-rev-list --all --author="%s" -n 1' % author)
|
|
55
|
62
|
rev_first = commands.getoutput('git-rev-list --all --author="%s" |tail -n 1' % author)
|
|
56
|
|
- stamp_last = int(commands.getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev_last))
|
|
57
|
|
- stamp_first = int(commands.getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev_first))
|
|
58
|
|
- date_first = datetime.datetime.fromtimestamp(stamp_first).strftime('%Y-%m-%d')
|
|
59
|
|
- date_last = datetime.datetime.fromtimestamp(stamp_last).strftime('%Y-%m-%d')
|
|
|
63
|
+ date_first = self.revToDate(rev_first)
|
|
|
64
|
+ date_last = self.revToDate(rev_last)
|
|
60
|
65
|
|
|
61
|
66
|
res = { 'commits': commits, 'commits_frac': commits_frac, 'date_first': date_first, 'date_last': date_last }
|
|
62
|
67
|
return res
|
|
|
@@ -66,17 +71,20 @@ class GitDataCollector(DataCollector):
|
|
66
|
71
|
return lines.split('\n')
|
|
67
|
72
|
|
|
68
|
73
|
def getTotalAuthors(self):
|
|
69
|
|
- return int(commands.getoutput('git-log |git-shortlog -s |wc -l'))
|
|
|
74
|
+ return self.total_authors
|
|
70
|
75
|
|
|
71
|
76
|
def getTotalCommits(self):
|
|
72
|
|
- return int(commands.getoutput('git-rev-list --all |wc -l'))
|
|
|
77
|
+ return self.total_commits
|
|
73
|
78
|
|
|
74
|
79
|
def getTotalFiles(self):
|
|
75
|
|
- files = commands.getoutput('git-ls-files |wc -l')
|
|
76
|
|
- return int(files)
|
|
|
80
|
+ return self.total_files
|
|
77
|
81
|
|
|
78
|
82
|
def getTotalLOC(self):
|
|
79
|
|
- return int(commands.getoutput('git-ls-files |xargs cat |wc -l'))
|
|
|
83
|
+ return self.total_lines
|
|
|
84
|
+
|
|
|
85
|
+ def revToDate(self, rev):
|
|
|
86
|
+ stamp = int(commands.getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev))
|
|
|
87
|
+ return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d')
|
|
80
|
88
|
|
|
81
|
89
|
class ReportCreator:
|
|
82
|
90
|
def __init__(self):
|
|
|
@@ -149,9 +157,11 @@ print 'Output path: %s' % outputpath
|
|
149
|
157
|
|
|
150
|
158
|
os.chdir(gitpath)
|
|
151
|
159
|
|
|
|
160
|
+print 'Collecting data...'
|
|
152
|
161
|
data = GitDataCollector()
|
|
153
|
162
|
data.collect(gitpath)
|
|
154
|
163
|
|
|
|
164
|
+print 'Generating report...'
|
|
155
|
165
|
report = HTMLReportCreator()
|
|
156
|
166
|
report.create(data, outputpath)
|
|
157
|
167
|
|