scratch/lib/gitmtime.rb
Yann Esposito (Yogsototh) 80f01b119e newblog entry
2010-09-02 16:42:39 +02:00

22 lines
537 B
Ruby

def gitmtime
filepath=@item.path.sub('/Scratch/','content/html/').sub(/\/$/,'')
ext=%{.#{@item[:extension]}}
filepath<<=ext
if not FileTest.exists?(filepath)
filepath.sub!(ext,%{/index#{ext}})
end
str=`git log -1 --format='%ci' -- #{filepath}`
puts '###'
puts filepath
puts str
puts '###'
if str.nil? or str.empty?
if @item.mtime.nil?
return Time.now
else
return @item.mtime
end
else
return DateTime.parse( str )
end
end