Created
October 4, 2016 13:47
-
-
Save jgn/b3dddf091db54b2d719fa02e996dc5a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# from https://stackoverflow.com/posts/24458934/revisions | |
require 'digest/sha1' | |
def git_hash(filename) | |
data = File.read(filename) | |
Digest::SHA1.hexdigest("blob #{data.bytesize.to_s}\0#{data}") | |
end | |
puts git_hash(ARGV[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment