Skip to content

Instantly share code, notes, and snippets.

@apeckham
Created May 31, 2012 15:10
Show Gist options
  • Save apeckham/2844037 to your computer and use it in GitHub Desktop.
Save apeckham/2844037 to your computer and use it in GitHub Desktop.
hash the contents of the public directory, inspired by http://grosser.it/2010/01/12/checksum-for-a-whole-folder-in-ruby/
def self.commit_hash
@commit_hash ||= begin
files = Dir["public/**/*"].select { |f| File.file?(f) }.sort
contents = files.map { |f| File.read(f) }.join
hash = Digest::MD5.hexdigest(contents)[0..6]
"rel-#{hash}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment