scratch/output/Scratch/en/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/code/gitmtime.rb
Yann Esposito (Yogsototh) 437be7e7cf Regen
2011-04-20 16:46:03 +02:00

15 lines
389 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}`
if str.nil? or str.empty?
return Time.now
else
return DateTime.parse( str )
end
end