Skip to content

Instantly share code, notes, and snippets.

@yogsototh
Created September 2, 2010 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yogsototh/562059 to your computer and use it in GitHub Desktop.
Save yogsototh/562059 to your computer and use it in GitHub Desktop.
def gitmtime
# find file extension
filepath=@item.path.sub('/Scratch/','content/html/').sub(/\/$/,'')
['md','erb','haml'].each do |ext|
tmppath=%{#{filepath}.#{ext}}
if FileTest.exists?(tmppath)
filepath=tmppath
break
end
end
str=`git log --format='%ci' -- #{filepath} | head -n 1`
# puts '#############'
# puts "item #{filepath}"
# puts "str #{str}"
# puts '#############'
if str == ""
return @item.mtime
else
return DateTime.parse( str )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment