浏览代码

(Stage 1)

Upgrade to python 3
Make this a module (and installable)
Refactor single file into discrete files
Dan Rapp 7 年前
父节点
当前提交
8a1570e61b
共有 15 个文件被更改,包括 1925 次插入1966 次删除
  1. 1
    0
      .gitattributes
  2. 2
    0
      .gitignore
  3. 3
    0
      MANIFEST.in
  4. 17
    0
      README.md
  5. 二进制
      arrow-down.gif
  6. 二进制
      arrow-none.gif
  7. 二进制
      arrow-up.gif
  8. 2
    5
      doc/AUTHOR
  9. 1
    1
      doc/gitstats.pod
  10. 0
    1491
      gitstats
  11. 0
    145
      gitstats.css
  12. 13
    0
      setup.cfg
  13. 64
    0
      setup.py
  14. 0
    324
      sortable.js
  15. 1822
    0
      versioneer.py

+ 1
- 0
.gitattributes 查看文件

@@ -0,0 +1 @@
1
+gitstats/_version.py export-subst

+ 2
- 0
.gitignore 查看文件

@@ -0,0 +1,2 @@
1
+**/__pycache__
2
+*.egg-info

+ 3
- 0
MANIFEST.in 查看文件

@@ -0,0 +1,3 @@
1
+include versioneer.py
2
+include gitstats/_version.py
3
+include gitstats/resources/*

+ 17
- 0
README.md 查看文件

@@ -0,0 +1,17 @@
1
+# GitStats
2
+
3
+A utility to pull a number of statistics from a git repo including:
4
+
5
+* Total LOC
6
+* LOC (by various time periods)
7
+* Commits (by various time periods)
8
+* Commits (by various authors)
9
+* Files (by type)
10
+* Files (by various time periods)
11
+* Tags (by date, authors, volume)
12
+
13
+## Usage
14
+
15
+`pip install gitstats`
16
+
17
+`gitstats <repo_dir>+ <output_dir>`

二进制
arrow-down.gif 查看文件


二进制
arrow-none.gif 查看文件


二进制
arrow-up.gif 查看文件


+ 2
- 5
doc/AUTHOR 查看文件

@@ -1,9 +1,6 @@
1
-Author can be reached by sending e-mail to <hoxu@users.sf.net>.
2
-Include "gitstats" in the subject or prepare to battle the spam filters.
1
+This work was forked from hoxu@users.sf.net and is authored by
2
+Daniel Rapp (rappdw@gmail.com)
3 3
 
4 4
 See the following command for list of authors who have contributed:
5 5
   $ git shortlog HEAD
6 6
 
7
-Also thanks to the following people:
8
-Alexander Botero-Lowry
9
-

+ 1
- 1
doc/gitstats.pod 查看文件

@@ -103,7 +103,7 @@ A: Use git .mailmap feature described in B<MAPPING AUTHORS> of L<git-shortlog(1)
103 103
 
104 104
 B<gitstats> was written by Heikki Hokkanen and others.
105 105
 
106
-See the git repository at https://github.com/hoxu/gitstats for an up-to-date full list of contributors.
106
+See the git repository at https://github.com/rappdw/gitstats for an up-to-date full list of contributors.
107 107
 
108 108
 =head1 WWW
109 109
 

+ 0
- 1491
gitstats
文件差异内容过多而无法显示
查看文件


+ 0
- 145
gitstats.css 查看文件

@@ -1,145 +0,0 @@
1
-/**
2
- * GitStats - default style
3
- */
4
-body {
5
-	color: black;
6
-	background-color: #dfd;
7
-}
8
-
9
-dt {
10
-	font-weight: bold;
11
-	float: left;
12
-	margin-right: 1em;
13
-}
14
-
15
-dt:after {
16
-	content: ': ';
17
-}
18
-
19
-dd {
20
-	display: block;
21
-	clear: left;
22
-}
23
-
24
-table {
25
-	border: 1px solid black;
26
-	border-collapse: collapse;
27
-	font-size: 80%;
28
-	margin-bottom: 1em;
29
-}
30
-
31
-table.noborders {
32
-	border: none;
33
-}
34
-
35
-table.noborders td {
36
-	border: none;
37
-}
38
-
39
-.vtable {
40
-	float: right;
41
-	clear: both;
42
-}
43
-
44
-table.tags td {
45
-	vertical-align: top;
46
-}
47
-
48
-td {
49
-	background-color: white;
50
-}
51
-
52
-th {
53
-	background-color: #ddf;
54
-}
55
-
56
-th a {
57
-	text-decoration: none;
58
-}
59
-
60
-tr:hover {
61
-	background-color: #ddf;
62
-}
63
-
64
-td {
65
-	border: 1px solid black;
66
-	padding: 0.2em;
67
-	padding-left: 0.3em;
68
-	padding-right: 0.2em;
69
-}
70
-
71
-/* Navigation bar; tabbed style */
72
-.nav {
73
-	border-bottom: 1px solid black;
74
-	padding: 0.3em;
75
-}
76
-
77
-.nav ul {
78
-	list-style-type: none;
79
-	display: inline;
80
-	margin: 0;
81
-	padding: 0;
82
-}
83
-
84
-.nav li {
85
-	display: inline;
86
-}
87
-
88
-.nav li a {
89
-	padding: 0.3em;
90
-	text-decoration: none;
91
-	color: black;
92
-	border: 1px solid black;
93
-	margin: 0.5em;
94
-	background-color: #ddf;
95
-}
96
-
97
-.nav li a:hover {
98
-	background-color: #ddd;
99
-	border-bottom: 1px solid #ddf;
100
-}
101
-
102
-img {
103
-	border: 1px solid black;
104
-	padding: 0.5em;
105
-	background-color: white;
106
-}
107
-
108
-th img {
109
-	border: 0px;
110
-	padding: 0px;
111
-	background-color: #ddf;
112
-}
113
-
114
-h1 a, h2 a {
115
-	color: black;
116
-	text-decoration: none;
117
-}
118
-
119
-h1:hover a:after,
120
-h2:hover a:after {
121
-	content: '¶';
122
-	color: #555;
123
-}
124
-
125
-h1 {
126
-	font-size: x-large;
127
-}
128
-
129
-h2 {
130
-	background-color: #564;
131
-	border: 1px solid black;
132
-	padding-left: 0.5em;
133
-	padding-right: 0.5em;
134
-	color: white;
135
-	font-size: large;
136
-	clear: both;
137
-}
138
-
139
-h2 a {
140
-	color: white;
141
-}
142
-
143
-.moreauthors {
144
-	font-size: 80%;
145
-}

+ 13
- 0
setup.cfg 查看文件

@@ -0,0 +1,13 @@
1
+
2
+# See the docstring in versioneer.py for instructions. Note that you must
3
+# re-run 'versioneer.py setup' after changing this section, and commit the
4
+# resulting files.
5
+
6
+[versioneer]
7
+VCS = git
8
+style = pep440
9
+versionfile_source = gitstats/_version.py
10
+versionfile_build = gitstats/_version.py
11
+tag_prefix =
12
+parentdir_prefix = gitstats-
13
+

+ 64
- 0
setup.py 查看文件

@@ -0,0 +1,64 @@
1
+import versioneer
2
+from setuptools import setup, find_packages
3
+
4
+setup(
5
+    name='gitstats',
6
+    version=versioneer.get_version(),
7
+    cmdclass=versioneer.get_cmdclass(),
8
+    description='gitstats',
9
+    long_description='Statistics for Git Repo',
10
+    url='',
11
+
12
+    author='rappdw',
13
+    author_email='rappdw@gmail.com',
14
+
15
+    license='MIT',
16
+    keywords='library',
17
+
18
+    classifiers=[
19
+        'Development Status :: 3 - Alpha',
20
+        'Intended Audience :: Developers',
21
+        # Set this topic to what works for you
22
+        'Topic :: Python :: Library',
23
+        # Pick your license as you wish (should match "license" above)
24
+        'License :: MIT',
25
+        'Programming Language :: Python :: 3.5',
26
+    ],
27
+
28
+    packages=find_packages(exclude=['contrib', 'docs', 'tests']),
29
+    include_package_data=True,
30
+
31
+    # Alternatively, if you want to distribute just a my_module.py, uncomment
32
+    # this:
33
+    #   py_modules=["my_module"],
34
+
35
+    setup_requires=[
36
+        # Setuptools 18.0 properly handles Cython extensions.
37
+        'setuptools>=18.0'
38
+    ],
39
+    install_requires=[
40
+    ],
41
+
42
+    extras_require={
43
+        'dev': [
44
+            'wheel>=0.30.0'
45
+        ],
46
+        'test': [
47
+        ],
48
+    },
49
+
50
+    package_data={
51
+        # 'sample': ['package_data.dat'],
52
+    },
53
+
54
+    entry_points={
55
+        'console_scripts': [
56
+            'gitstats = gitstats:main',
57
+        ],
58
+    },
59
+    # entry_points={
60
+        # 'console_scripts': [
61
+            # 'sample=sample:main',
62
+        # ],
63
+    # },
64
+)

+ 0
- 324
sortable.js 查看文件

@@ -1,324 +0,0 @@
1
-/*
2
-Table sorting script  by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/.
3
-Based on a script from http://www.kryogenix.org/code/browser/sorttable/.
4
-Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html .
5
-
6
-Copyright (c) 1997-2007 Stuart Langridge, Joost de Valk.
7
-
8
-Version 1.5.7
9
-*/
10
-
11
-/* You can change these values */
12
-var image_path = "";
13
-var image_up = "arrow-up.gif";
14
-var image_down = "arrow-down.gif";
15
-var image_none = "arrow-none.gif";
16
-var europeandate = true;
17
-var alternate_row_colors = true;
18
-
19
-/* Don't change anything below this unless you know what you're doing */
20
-addEvent(window, "load", sortables_init);
21
-
22
-var SORT_COLUMN_INDEX;
23
-var thead = false;
24
-
25
-function sortables_init() {
26
-	// Find all tables with class sortable and make them sortable
27
-	if (!document.getElementsByTagName) return;
28
-	tbls = document.getElementsByTagName("table");
29
-	for (ti=0;ti<tbls.length;ti++) {
30
-		thisTbl = tbls[ti];
31
-		if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
32
-			ts_makeSortable(thisTbl);
33
-		}
34
-	}
35
-}
36
-
37
-function ts_makeSortable(t) {
38
-	if (t.rows && t.rows.length > 0) {
39
-		if (t.tHead && t.tHead.rows.length > 0) {
40
-			var firstRow = t.tHead.rows[t.tHead.rows.length-1];
41
-			thead = true;
42
-		} else {
43
-			var firstRow = t.rows[0];
44
-		}
45
-	}
46
-	if (!firstRow) return;
47
-	
48
-	// We have a first row: assume it's the header, and make its contents clickable links
49
-	for (var i=0;i<firstRow.cells.length;i++) {
50
-		var cell = firstRow.cells[i];
51
-		var txt = ts_getInnerText(cell);
52
-		if (cell.className != "unsortable" && cell.className.indexOf("unsortable") == -1) {
53
-			cell.innerHTML = '<a href="#" class="sortheader" onclick="ts_resortTable(this, '+i+');return false;">'+txt+'<span class="sortarrow">&nbsp;&nbsp;<img src="'+ image_path + image_none + '" alt="&darr;"/></span></a>';
54
-		}
55
-	}
56
-	if (alternate_row_colors) {
57
-		alternate(t);
58
-	}
59
-}
60
-
61
-function ts_getInnerText(el) {
62
-	if (typeof el == "string") return el;
63
-	if (typeof el == "undefined") { return el };
64
-	if (el.innerText) return el.innerText;	//Not needed but it is faster
65
-	var str = "";
66
-	
67
-	var cs = el.childNodes;
68
-	var l = cs.length;
69
-	for (var i = 0; i < l; i++) {
70
-		switch (cs[i].nodeType) {
71
-			case 1: //ELEMENT_NODE
72
-				str += ts_getInnerText(cs[i]);
73
-				break;
74
-			case 3:	//TEXT_NODE
75
-				str += cs[i].nodeValue;
76
-				break;
77
-		}
78
-	}
79
-	return str;
80
-}
81
-
82
-function ts_resortTable(lnk, clid) {
83
-	var span;
84
-	for (var ci=0;ci<lnk.childNodes.length;ci++) {
85
-		if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
86
-	}
87
-	var spantext = ts_getInnerText(span);
88
-	var td = lnk.parentNode;
89
-	var column = clid || td.cellIndex;
90
-	var t = getParent(td,'TABLE');
91
-	// Work out a type for the column
92
-	if (t.rows.length <= 1) return;
93
-	var itm = "";
94
-	var i = 1;
95
-	while (itm == "" && i < t.tBodies[0].rows.length) {
96
-		var itm = ts_getInnerText(t.tBodies[0].rows[i].cells[column]);
97
-		itm = trim(itm);
98
-		if (itm.substr(0,4) == "<!--" || itm.length == 0) {
99
-			itm = "";
100
-		}
101
-		i++;
102
-	}
103
-	if (itm == "") return; 
104
-	sortfn = ts_sort_caseinsensitive;
105
-	if (itm.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d\d\d\d$/)) sortfn = ts_sort_date;
106
-	if (itm.match(/^\d\d[\/\.-]\d\d[\/\.-]\d\d\d{2}?$/)) sortfn = ts_sort_date;
107
-	if (itm.match(/^-?[£$€Û¢´]\d/)) sortfn = ts_sort_numeric;
108
-	// ignore stuff in () after the numbers.
109
-	if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?( \(.*\))?$/)) sortfn = ts_sort_numeric;
110
-	SORT_COLUMN_INDEX = column;
111
-	var firstRow = new Array();
112
-	var newRows = new Array();
113
-	for (k=0;k<t.tBodies.length;k++) {
114
-		for (i=0;i<t.tBodies[k].rows[0].length;i++) { 
115
-			firstRow[i] = t.tBodies[k].rows[0][i]; 
116
-		}
117
-	}
118
-	for (k=0;k<t.tBodies.length;k++) {
119
-		if (!thead) {
120
-			// Skip the first row
121
-			for (j=1;j<t.tBodies[k].rows.length;j++) { 
122
-				newRows[j-1] = t.tBodies[k].rows[j];
123
-			}
124
-		} else {
125
-			// Do NOT skip the first row
126
-			for (j=0;j<t.tBodies[k].rows.length;j++) { 
127
-				newRows[j] = t.tBodies[k].rows[j];
128
-			}
129
-		}
130
-	}
131
-	newRows.sort(sortfn);
132
-	if (span.getAttribute("sortdir") == 'down') {
133
-			ARROW = '&nbsp;&nbsp;<img src="'+ image_path + image_down + '" alt="&darr;"/>';
134
-			newRows.reverse();
135
-			span.setAttribute('sortdir','up');
136
-	} else {
137
-			ARROW = '&nbsp;&nbsp;<img src="'+ image_path + image_up + '" alt="&uarr;"/>';
138
-			span.setAttribute('sortdir','down');
139
-	} 
140
-    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
141
-    // don't do sortbottom rows
142
-    for (i=0; i<newRows.length; i++) { 
143
-		if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) {
144
-			t.tBodies[0].appendChild(newRows[i]);
145
-		}
146
-	}
147
-    // do sortbottom rows only
148
-    for (i=0; i<newRows.length; i++) {
149
-		if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) 
150
-			t.tBodies[0].appendChild(newRows[i]);
151
-	}
152
-	// Delete any other arrows there may be showing
153
-	var allspans = document.getElementsByTagName("span");
154
-	for (var ci=0;ci<allspans.length;ci++) {
155
-		if (allspans[ci].className == 'sortarrow') {
156
-			if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
157
-				allspans[ci].innerHTML = '&nbsp;&nbsp;<img src="'+ image_path + image_none + '" alt="&darr;"/>';
158
-			}
159
-		}
160
-	}		
161
-	span.innerHTML = ARROW;
162
-	alternate(t);
163
-}
164
-
165
-function getParent(el, pTagName) {
166
-	if (el == null) {
167
-		return null;
168
-	} else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) {
169
-		return el;
170
-	} else {
171
-		return getParent(el.parentNode, pTagName);
172
-	}
173
-}
174
-
175
-function sort_date(date) {	
176
-	// y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
177
-	dt = "00000000";
178
-	if (date.length == 11) {
179
-		mtstr = date.substr(3,3);
180
-		mtstr = mtstr.toLowerCase();
181
-		switch(mtstr) {
182
-			case "jan": var mt = "01"; break;
183
-			case "feb": var mt = "02"; break;
184
-			case "mar": var mt = "03"; break;
185
-			case "apr": var mt = "04"; break;
186
-			case "may": var mt = "05"; break;
187
-			case "jun": var mt = "06"; break;
188
-			case "jul": var mt = "07"; break;
189
-			case "aug": var mt = "08"; break;
190
-			case "sep": var mt = "09"; break;
191
-			case "oct": var mt = "10"; break;
192
-			case "nov": var mt = "11"; break;
193
-			case "dec": var mt = "12"; break;
194
-			// default: var mt = "00";
195
-		}
196
-		dt = date.substr(7,4)+mt+date.substr(0,2);
197
-		return dt;
198
-	} else if (date.length == 10) {
199
-		if (europeandate == false) {
200
-			dt = date.substr(6,4)+date.substr(0,2)+date.substr(3,2);
201
-			return dt;
202
-		} else {
203
-			dt = date.substr(6,4)+date.substr(3,2)+date.substr(0,2);
204
-			return dt;
205
-		}
206
-	} else if (date.length == 8) {
207
-		yr = date.substr(6,2);
208
-		if (parseInt(yr) < 50) { 
209
-			yr = '20'+yr; 
210
-		} else { 
211
-			yr = '19'+yr; 
212
-		}
213
-		if (europeandate == true) {
214
-			dt = yr+date.substr(3,2)+date.substr(0,2);
215
-			return dt;
216
-		} else {
217
-			dt = yr+date.substr(0,2)+date.substr(3,2);
218
-			return dt;
219
-		}
220
-	}
221
-	return dt;
222
-}
223
-
224
-function ts_sort_date(a,b) {
225
-	dt1 = sort_date(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
226
-	dt2 = sort_date(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
227
-	
228
-	if (dt1==dt2) {
229
-		return 0;
230
-	}
231
-	if (dt1<dt2) { 
232
-		return -1;
233
-	}
234
-	return 1;
235
-}
236
-function ts_sort_numeric(a,b) {
237
-	var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
238
-	aa = clean_num(aa);
239
-	var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
240
-	bb = clean_num(bb);
241
-	return compare_numeric(aa,bb);
242
-}
243
-function compare_numeric(a,b) {
244
-	var a = parseFloat(a);
245
-	a = (isNaN(a) ? 0 : a);
246
-	var b = parseFloat(b);
247
-	b = (isNaN(b) ? 0 : b);
248
-	return a - b;
249
-}
250
-function ts_sort_caseinsensitive(a,b) {
251
-	aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
252
-	bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
253
-	if (aa==bb) {
254
-		return 0;
255
-	}
256
-	if (aa<bb) {
257
-		return -1;
258
-	}
259
-	return 1;
260
-}
261
-function ts_sort_default(a,b) {
262
-	aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
263
-	bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
264
-	if (aa==bb) {
265
-		return 0;
266
-	}
267
-	if (aa<bb) {
268
-		return -1;
269
-	}
270
-	return 1;
271
-}
272
-function addEvent(elm, evType, fn, useCapture)
273
-// addEvent and removeEvent
274
-// cross-browser event handling for IE5+,	NS6 and Mozilla
275
-// By Scott Andrew
276
-{
277
-	if (elm.addEventListener){
278
-		elm.addEventListener(evType, fn, useCapture);
279
-		return true;
280
-	} else if (elm.attachEvent){
281
-		var r = elm.attachEvent("on"+evType, fn);
282
-		return r;
283
-	} else {
284
-		alert("Handler could not be removed");
285
-	}
286
-}
287
-function clean_num(str) {
288
-	str = str.replace(new RegExp(/[^-?0-9.]/g),"");
289
-	return str;
290
-}
291
-function trim(s) {
292
-	return s.replace(/^\s+|\s+$/g, "");
293
-}
294
-function alternate(table) {
295
-	// Take object table and get all it's tbodies.
296
-	var tableBodies = table.getElementsByTagName("tbody");
297
-	// Loop through these tbodies
298
-	for (var i = 0; i < tableBodies.length; i++) {
299
-		// Take the tbody, and get all it's rows
300
-		var tableRows = tableBodies[i].getElementsByTagName("tr");
301
-		// Loop through these rows
302
-		// Start at 1 because we want to leave the heading row untouched
303
-		for (var j = 0; j < tableRows.length; j++) {
304
-			// Check if j is even, and apply classes for both possible results
305
-			if ( (j % 2) == 0  ) {
306
-				if ( !(tableRows[j].className.indexOf('odd') == -1) ) {
307
-					tableRows[j].className = tableRows[j].className.replace('odd', 'even');
308
-				} else {
309
-					if ( tableRows[j].className.indexOf('even') == -1 ) {
310
-						tableRows[j].className += " even";
311
-					}
312
-				}
313
-			} else {
314
-				if ( !(tableRows[j].className.indexOf('even') == -1) ) {
315
-					tableRows[j].className = tableRows[j].className.replace('even', 'odd');
316
-				} else {
317
-					if ( tableRows[j].className.indexOf('odd') == -1 ) {
318
-						tableRows[j].className += " odd";
319
-					}
320
-				}
321
-			} 
322
-		}
323
-	}
324
-}

+ 1822
- 0
versioneer.py
文件差异内容过多而无法显示
查看文件