Browse Source

More todo items and stubs.

Heikki Hokkanen 18 years ago
parent
commit
c00bb58dbe
3 changed files with 75 additions and 21 deletions
  1. 20
    9
      TODO.txt
  2. 35
    12
      statgit
  3. 20
    0
      statgit.css

+ 20
- 9
TODO.txt View File

1
 - development statistics generator for git
1
 - development statistics generator for git
2
 	- should be as versatile as statcvs / statsvn
2
 	- should be as versatile as statcvs / statsvn
3
 
3
 
4
-- language?
5
-	- perl or python?
6
-
7
-- make git data collection part separate so that portage to other DVCS's is easier
8
-	- DataCollector
9
-
10
-- make output thingies modular as well (HTML first, plain text later etc)
11
-	- ReportCreator
12
-
13
 [Information]
4
 [Information]
14
 - git-log
5
 - git-log
15
 - git-ls-files
6
 - git-ls-files
19
 - git-rev-list --all
10
 - git-rev-list --all
20
 	- first and last commit
11
 	- first and last commit
21
 - git-show-ref --tags
12
 - git-show-ref --tags
13
+	- not all tags are tags on refs?
22
 - git-log |git-shortlog -s
14
 - git-log |git-shortlog -s
23
 	- author: number of commits
15
 	- author: number of commits
24
 - git-what-changed
16
 - git-what-changed
33
 
25
 
34
 - Authors
26
 - Authors
35
 	- List of authors
27
 	- List of authors
28
+		- show only first 10 and rest on separate page?
36
 	- DONE (T): author, commits (%), LOC?, first commit, last commit
29
 	- DONE (T): author, commits (%), LOC?, first commit, last commit
37
 	- (T): Developer of the Month: month, author, commits, LOC?
30
 	- (T): Developer of the Month: month, author, commits, LOC?
38
 
31
 
32
+- Files
33
+	- Total Files
34
+	- Average file size
35
+	- Average revisions per file
36
+	- (G) File Count: x = date, y = files
37
+	- (G) Average file size: x = date, y = lines/file
38
+	- (T) File Extensions (or mime types from "file"?): extension, files (%), lines (%), lines/file
39
+	- (T) Largest Files?
40
+	- (T) Files With Most Revisions?
41
+
42
+- Activity by Time?
43
+	- Hour of Day
44
+	- Day of Week (+ Hour of weekday -> 7x24)
45
+	- Month of Year
46
+	- (G?) Last 30 days
47
+	- (G?) Last 12 months
48
+
39
 - (G) Lines of Code: x = date, y = lines
49
 - (G) Lines of Code: x = date, y = lines
40
 
50
 
41
 - Tags
51
 - Tags
102
 
112
 
103
 [Misc]
113
 [Misc]
104
 - use sortable.js ?
114
 - use sortable.js ?
115
+- could show some statistics from last year, month, etc... pisg-like?

+ 35
- 12
statgit View File

7
 import re
7
 import re
8
 import sys
8
 import sys
9
 
9
 
10
+def getoutput(cmd):
11
+	print '>> %s' % cmd
12
+	output = commands.getoutput(cmd)
13
+	return output
14
+
10
 class DataCollector:
15
 class DataCollector:
11
 	def __init__(self):
16
 	def __init__(self):
12
 		pass
17
 		pass
17
 		self.dir = dir
22
 		self.dir = dir
18
 	
23
 	
19
 	##
24
 	##
20
-	# TODO: get a dictionary of author
25
+	# : get a dictionary of author
21
 	def getAuthorInfo(self, author):
26
 	def getAuthorInfo(self, author):
22
 		return None
27
 		return None
23
 	
28
 	
32
 	def getLastCommitDate(self):
37
 	def getLastCommitDate(self):
33
 		return datetime.datetime.now()
38
 		return datetime.datetime.now()
34
 	
39
 	
40
+	def getTags(self):
41
+		return []
42
+	
35
 	def getTotalAuthors(self):
43
 	def getTotalAuthors(self):
36
 		return -1
44
 		return -1
37
 	
45
 	
48
 	def collect(self, dir):
56
 	def collect(self, dir):
49
 		DataCollector.collect(self, dir)
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
 	def getAuthorInfo(self, author):
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
 		commits_frac = (100 * float(commits)) / self.getTotalCommits()
66
 		commits_frac = (100 * float(commits)) / self.getTotalCommits()
59
 		date_first = '0000-00-00'
67
 		date_first = '0000-00-00'
60
 		date_last = '0000-00-00'
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
 		date_first = self.revToDate(rev_first)
71
 		date_first = self.revToDate(rev_first)
64
 		date_last = self.revToDate(rev_last)
72
 		date_last = self.revToDate(rev_last)
65
 
73
 
67
 		return res
75
 		return res
68
 	
76
 	
69
 	def getAuthors(self):
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
 		return lines.split('\n')
83
 		return lines.split('\n')
72
 	
84
 	
85
+	def getTagDate(self, tag):
86
+		return self.revToDate('tags/' + tag)
87
+	
73
 	def getTotalAuthors(self):
88
 	def getTotalAuthors(self):
74
 		return self.total_authors
89
 		return self.total_authors
75
 	
90
 	
83
 		return self.total_lines
98
 		return self.total_lines
84
 	
99
 	
85
 	def revToDate(self, rev):
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
 		return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d')
102
 		return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d')
88
 
103
 
89
 class ReportCreator:
104
 class ReportCreator:
102
 		f.write("""<html>
117
 		f.write("""<html>
103
 <head>
118
 <head>
104
 	<title>StatGit</title>
119
 	<title>StatGit</title>
120
+	<link rel="stylesheet" href="statgit.css" type="text/css" />
105
 </head>
121
 </head>
106
 <body>
122
 <body>
107
 """)
123
 """)
118
 		f.write('<dt>Authors</dt><dd>%s</dd>' % data.getTotalAuthors())
134
 		f.write('<dt>Authors</dt><dd>%s</dd>' % data.getTotalAuthors())
119
 		f.write('</dl>');
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
 		f.write('<h2>Authors</h2>')
144
 		f.write('<h2>Authors</h2>')
122
 
145
 
123
 		f.write('<table class="authors">')
146
 		f.write('<table class="authors">')
128
 		f.write('</table>')
151
 		f.write('</table>')
129
 
152
 
130
 		f.write('<h2>Tags</h2>')
153
 		f.write('<h2>Tags</h2>')
131
-
132
 		f.write('<table>')
154
 		f.write('<table>')
133
 		f.write('<tr><th>Name</th><th>Date</th><th>Developers</th></tr>')
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
 		f.write('</table>')
158
 		f.write('</table>')
136
 
159
 
137
 		f.write('</body>\n</html>');
160
 		f.write('</body>\n</html>');

+ 20
- 0
statgit.css View File

1
+body {
2
+	color: black;
3
+	background-color: #cc9;
4
+}
5
+
6
+dt {
7
+	font-weight: bold;
8
+	float: left;
9
+	margin-right: 1em;
10
+}
11
+
12
+dt:after {
13
+	content: ': ';
14
+}
15
+
16
+dd {
17
+	display: block;
18
+	clear: right;
19
+}
20
+