diff --git a/bin/git-timecost b/bin/git-timecost index 26eeb28..12c879e 100755 --- a/bin/git-timecost +++ b/bin/git-timecost @@ -25,7 +25,7 @@ class GitExtractor def initialize config, commit @config = config @time_stop = DateTime.parse(commit.date) - @time_start = @time_stop - (1.5 / 24.0) + @time_start = @time_stop - (@config[:range_granularity] * 3 / 24.0) @commits = [commit] self end @@ -101,7 +101,7 @@ class GitExtractor end def fixed_start - return @time_start + (0.5/24.0) + return @time_start + (@config[:range_granularity]/24.0) end def diff @@ -181,6 +181,8 @@ class GitExtractor :input_dump => [], :output_dump => nil, + :range_granularity => 0.5, # in decimal hours + :verbose => false } @rangelist = nil @@ -225,6 +227,13 @@ class GitExtractor @config[:author_filter] = author @config[:author_filter_enable] = true end + + # overlap : + # + opts.on("-s","--scotch GRANULARITY", "Use GRANULARITY (decimal hours) to merge ranges") do |granularity| + puts "set scotch to #{granularity}" + @config[:range_granularity] = granularity.to_f + end end opts.parse! args @@ -234,7 +243,10 @@ class GitExtractor def analyze_git # git log # foreach, create time range (before) + logs - process = IO.popen ["git", "log", "--date=iso"] + process = IO.popen ["git", "log", + "--date=iso", + "--no-patch", + "--","."] @rangelist = RangeList.new @@ -242,6 +254,8 @@ class GitExtractor loop do line = process.gets break if line.nil? + # utf-8 fix ? + # line.encode!( line.encoding, "binary", :invalid => :replace, :undef => :replace) line.strip! case line @@ -253,7 +267,7 @@ class GitExtractor @rangelist.add range end commit = Commit.new id - #puts "commit #{id}" + # puts "commit #{id}" when /^Author:\s*(.*?)\s*$/ then unless commit.nil? then @@ -289,8 +303,6 @@ class GitExtractor end end - def exec - end end end