module Siteleaf::GitHash

Public Class Methods

file(filename) click to toggle source

equivalent of `git hash-object file.txt`

# File lib/siteleaf/git_hash.rb, line 4
def self.file(filename)
  ::File.open(filename, 'r') do |f|
    Digest::SHA1.hexdigest("blob #{f.size}\0#{f.read}")
  end
end
string(str) click to toggle source
# File lib/siteleaf/git_hash.rb, line 10
def self.string(str)
  Digest::SHA1.hexdigest("blob #{str.bytesize}\0#{str}")
end