forked from lastorset/bindir
-
Notifications
You must be signed in to change notification settings - Fork 1
/
git-masstimecard
executable file
·48 lines (39 loc) · 1.18 KB
/
git-masstimecard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
"""Show a timecard across all projects.
For printing a chart (the default), pygooglechart is required:
http://pygooglechart.slowchop.com/
Note that this assumes you've got an OS-X style "open" command. If
you don't, it should be easy enough to adapt main to what you need.
"""
import os
import sys
import exceptions
import gitaggregates
def resolve(path):
dotgit = os.path.join(path, ".git")
objects = os.path.join(path, "objects")
if os.path.isdir(dotgit):
return resolve(dotgit)
elif os.path.isdir(objects):
return path
sys.stderr.write("Warning: Can't find a git repo for %s\n" % path)
if __name__ == '__main__':
th = gitaggregates.TimeHisto()
# Separate log args from repo args
repos = []
log_args = []
current = repos
for a in sys.argv[1:]:
if log_args is current:
log_args.append(a)
else:
if a == '--':
current = log_args
else:
p = resolve(a)
if p:
repos.append(p)
th = gitaggregates.TimeHisto()
for r in repos:
th.add_logs(r, log_args)
gitaggregates.open_chart(th)