Final cleanup for per-author range.

This commit is contained in:
@@@No user configured@@@ 2014-09-25 09:13:05 +02:00
parent 229fd0a42f
commit d4efb11e44
3 changed files with 23 additions and 11 deletions

View file

@ -16,7 +16,7 @@ module TimeCost
:verbose => false :verbose => false
} }
@rangelist = nil @rangelist = {}
@authorlist = nil @authorlist = nil
end end
@ -81,7 +81,7 @@ module TimeCost
"--","."] "--","."]
@rangelist = RangeList.new @rangelist = {}
commit = nil commit = nil
loop do loop do
line = process.gets line = process.gets
@ -96,7 +96,11 @@ module TimeCost
# merge ranges & push # merge ranges & push
unless commit.nil? then unless commit.nil? then
range = Range.new @config, commit range = Range.new @config, commit
@rangelist.add range
if not @rangelist.include? commit.author then
@rangelist[commit.author] = RangeList.new
end
@rangelist[commit.author].add range
end end
commit = Commit.new id commit = Commit.new id
# puts "commit #{id}" # puts "commit #{id}"
@ -110,6 +114,7 @@ module TimeCost
commit = nil commit = nil
# reject # reject
end end
end end
when /^Date:\s*(.*?)\s*$/ then when /^Date:\s*(.*?)\s*$/ then
@ -170,10 +175,17 @@ module TimeCost
def report def report
return if not @config[:output_dump].nil? return if not @config[:output_dump].nil?
@rangelist.each do |r| @rangelist.each do |author,rangelist|
puts r.to_s + "\n" rangelist.each do |range|
puts range.to_s + "\n"
end
end end
puts "TOTAL: %.2f hours" % @rangelist.sum total = 0
@rangelist.each do |author,rangelist|
puts "SUB-TOTAL for %s: %.2f hours\n" % [author, rangelist.sum]
total += rangelist.sum
end
puts "TOTAL: %.2f hours" % total
end end
end end
end end

View file

@ -97,12 +97,12 @@ module TimeCost
end end
def to_s def to_s
val = "(%s) %s - %s\n" % [diff, fixed_start, @time_stop] val = "(%s)\t%s - %s\n" % [diff, fixed_start, @time_stop]
unless @config[:author_filter_enable] then
val += "\tby %s\n" % @commits.first.author
end
@commits.each do |commit| @commits.each do |commit|
lines = [] lines = []
unless @config[:author_filter_enable] then
lines.push commit.author
end
lines.concat commit.note.split(/\n/) lines.concat commit.note.split(/\n/)
r = lines.map{ |s| "\t %s" % s }.join "\n" r = lines.map{ |s| "\t %s" % s }.join "\n"
r[1] = '*' r[1] = '*'

View file

@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.email = ["glenux@glenux.net"] spec.email = ["glenux@glenux.net"]
spec.summary = %q{Use GIT logs to give an estimation of spent time & costs of your projects.} spec.summary = %q{Use GIT logs to give an estimation of spent time & costs of your projects.}
spec.description = %q{Use GIT logs to give an estimation of spent time & costs of your projects.} spec.description = %q{Use GIT logs to give an estimation of spent time & costs of your projects.}
spec.homepage = "https//github.com/glenux/git-timecost" spec.homepage = "https://github.com/glenux/git-timecost"
spec.license = "MIT" spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0") spec.files = `git ls-files -z`.split("\x0")