lib/gitwakatime/commit.rb in gitwakatime-0.2.2 vs lib/gitwakatime/commit.rb in gitwakatime-0.4.0
- old
+ new
@@ -3,27 +3,31 @@
# Cache git commit and correlate it's children
#
class Commit < Sequel::Model
one_to_many :commited_files
def after_create
- extract_changed_files
+ extract_changed_files if GitWakaTime.config.git
end
def to_s
format(' %-8s %8s %-30s %-80s'.green,
sha[0..8],
date,
ChronicDuration.output(time_in_seconds.to_i),
message
- )
+ )
end
def oldest_dependent
@files.sort { |f| f.commit.date }.first
end
def time_in_seconds
- commited_files.map(&:time_in_seconds).inject(:+)
+ commited_files.map(&:time_in_seconds).compact.inject(:+)
+ end
+
+ def date
+ self[:date].localtime
end
private
def extract_changed_files