total hours worked for each user per repository/project added

This commit is contained in:
Alexandre Dulaunoy 2012-05-26 12:34:52 +02:00
parent d4a658eb4b
commit 07e130b739

View file

@ -39,7 +39,14 @@ def logmessage(name = None, email = None, when = None, message = None, repo = No
logmessage = "" logmessage = ""
t=datetime.datetime.fromtimestamp(when) t=datetime.datetime.fromtimestamp(when)
d=t-datetime.timedelta(hours=commitfactor) d=t-datetime.timedelta(hours=commitfactor)
if options.total:
projectkey= repo+":"+name
if projectkey in projecttime:
projecttime[projectkey] += commitfactor
else:
projecttime[projectkey] = commitfactor
logmessage = "From "+d.ctime()+" to "+t.ctime() + "\n" logmessage = "From "+d.ctime()+" to "+t.ctime() + "\n"
logmessage += " "+name+" ("+email+") worked on "+ repo +"\n" logmessage += " "+name+" ("+email+") worked on "+ repo +"\n"
logmessage += " and did the following: "+ message +"\n" logmessage += " and did the following: "+ message +"\n"
@ -47,11 +54,15 @@ def logmessage(name = None, email = None, when = None, message = None, repo = No
usage = "usage: %s path_to_git_repos" % sys.argv[0] usage = "usage: %s path_to_git_repos" % sys.argv[0]
parser = OptionParser(usage) parser = OptionParser(usage)
parser.add_option("-d", "--debug", action="store_true" ,dest="debug", help="output debug messages", default=False) parser.add_option("-d", "--debug", action="store_true", dest="debug", help="output debug messages", default=False)
parser.add_option("-w", "--commitfactor", dest="commitfactor", help="work time factor per commit, default is 4 hours",default=4, type="int") parser.add_option("-w", "--commitfactor", dest="commitfactor", help="work time factor per commit, default is 4 hours",default=4, type="int")
parser.add_option("-t", "--total", action="store_true", dest="total", help="total hours worked for each user per repository/project", default=False)
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if options.total:
projecttime = {}
for repo in args: for repo in args:
val = gitlog(location = repo) val = gitlog(location = repo)
if options.debug: if options.debug:
@ -63,4 +74,7 @@ for repo in args:
continue continue
print logmessage(name=unicode(name), email=email, when=float(when), commitfactor = options.commitfactor, message=unicode(message), repo = os.path.basename(os.path.normpath(repo))) print logmessage(name=unicode(name), email=email, when=float(when), commitfactor = options.commitfactor, message=unicode(message), repo = os.path.basename(os.path.normpath(repo)))
if options.total:
for x in projecttime:
print x + "->" + unicode(projecttime[x])+" hours."