浏览代码

More todo items and stubs.

Heikki Hokkanen 18 年前
父节点
当前提交
c00bb58dbe
共有 3 个文件被更改,包括 75 次插入21 次删除
  1. 20
    9
      TODO.txt
  2. 35
    12
      statgit
  3. 20
    0
      statgit.css

+ 20
- 9
TODO.txt 查看文件

@@ -1,15 +1,6 @@
1 1
 - development statistics generator for git
2 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 4
 [Information]
14 5
 - git-log
15 6
 - git-ls-files
@@ -19,6 +10,7 @@
19 10
 - git-rev-list --all
20 11
 	- first and last commit
21 12
 - git-show-ref --tags
13
+	- not all tags are tags on refs?
22 14
 - git-log |git-shortlog -s
23 15
 	- author: number of commits
24 16
 - git-what-changed
@@ -33,9 +25,27 @@
33 25
 
34 26
 - Authors
35 27
 	- List of authors
28
+		- show only first 10 and rest on separate page?
36 29
 	- DONE (T): author, commits (%), LOC?, first commit, last commit
37 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 49
 - (G) Lines of Code: x = date, y = lines
40 50
 
41 51
 - Tags
@@ -102,3 +112,4 @@
102 112
 
103 113
 [Misc]
104 114
 - use sortable.js ?
115
+- could show some statistics from last year, month, etc... pisg-like?

+ 35
- 12
statgit 查看文件

@@ -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>');

+ 20
- 0
statgit.css 查看文件

@@ -0,0 +1,20 @@
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
+