|
@@ -8,6 +8,7 @@ import datetime
|
8
|
8
|
import shutil
|
9
|
9
|
import sys
|
10
|
10
|
import tempfile
|
|
11
|
+import time
|
11
|
12
|
import warnings
|
12
|
13
|
|
13
|
14
|
import git
|
|
@@ -22,7 +23,12 @@ def main():
|
22
|
23
|
repo = TempRemoteRepo(args.url, silent=args.silent)
|
23
|
24
|
|
24
|
25
|
commit_stats = {}
|
25
|
|
- for commit in repo:
|
|
26
|
+ last_progress = time.time()
|
|
27
|
+ for i, commit in enumerate(repo):
|
|
28
|
+ if not args.silent and time.time() - last_progress > 0.1:
|
|
29
|
+ last_progress = time.time()
|
|
30
|
+ print(f"Processing commit {f'#{i}':5s}", end="\r",
|
|
31
|
+ file=sys.stderr)
|
26
|
32
|
commit_datetime = commit.authored_datetime
|
27
|
33
|
if args.from_date is not None and \
|
28
|
34
|
args.from_date > commit_datetime.date():
|
|
@@ -46,7 +52,10 @@ def main():
|
46
|
52
|
return
|
47
|
53
|
|
48
|
54
|
if args.csv_output is None:
|
49
|
|
- print(result_cli(commit_stats, args.details))
|
|
55
|
+ if args.group_by or args.details:
|
|
56
|
+ print(result_cli(commit_stats, args.details))
|
|
57
|
+ else:
|
|
58
|
+ print(short_result_cli(commit_stats))
|
50
|
59
|
else:
|
51
|
60
|
result_csv(commit_stats, args.csv_output)
|
52
|
61
|
args.csv_output.close()
|
|
@@ -244,6 +253,7 @@ def result_csv(commit_stats, ofd=sys.stdout):
|
244
|
253
|
for kval, val in values.items()})
|
245
|
254
|
writer.writerow(row)
|
246
|
255
|
|
|
256
|
+
|
247
|
257
|
def result_cli(commit_stats, details=True):
|
248
|
258
|
""" Format stats for cli output
|
249
|
259
|
|
|
@@ -251,7 +261,7 @@ def result_cli(commit_stats, details=True):
|
251
|
261
|
- commit_stats : A dict with author as key and stats as values (
|
252
|
262
|
see commit_by_author() )
|
253
|
263
|
|
254
|
|
- Returns a string representing an ascii array with precentage of commits
|
|
264
|
+ Returns a string representing an ascii array with percentage of commits
|
255
|
265
|
off office hours.
|
256
|
266
|
"""
|
257
|
267
|
|
|
@@ -274,7 +284,7 @@ def result_cli(commit_stats, details=True):
|
274
|
284
|
hsep += "\n"
|
275
|
285
|
|
276
|
286
|
if details:
|
277
|
|
- header = f"| Author |"
|
|
287
|
+ header = "| Author |"
|
278
|
288
|
header += f"{'% off':>{author_width - len('Author |') - 2}s} |"
|
279
|
289
|
for key in all_keys:
|
280
|
290
|
header += f"{key:>{stat_width-1}s} |"
|
|
@@ -310,6 +320,23 @@ def result_cli(commit_stats, details=True):
|
310
|
320
|
|
311
|
321
|
return result
|
312
|
322
|
|
|
323
|
+
|
|
324
|
+def short_result_cli(commit_stats):
|
|
325
|
+ """ Format stats for cli output when no grouping
|
|
326
|
+
|
|
327
|
+ Arguments :
|
|
328
|
+ - commit_stats : A dict with author as key and stats as values (
|
|
329
|
+ see commit_by_author() )
|
|
330
|
+
|
|
331
|
+ Returns a printable string of author and their details about
|
|
332
|
+ commits off office hours.
|
|
333
|
+ """
|
|
334
|
+ return '\n'.join([f"{author.name:>20s} : \
|
|
335
|
+{stat['all']['off_oh']/stat['all']['total']*100:5.1f}% \
|
|
336
|
+( {stat['all']['off_oh']:4d}/{stat['all']['total']:<5d} off)"
|
|
337
|
+ for author, stat in commit_stats.items()])
|
|
338
|
+
|
|
339
|
+
|
313
|
340
|
def valid_day(value):
|
314
|
341
|
""" Take a locale dayname and convert it to a day number
|
315
|
342
|
|