Created
December 20, 2013 15:22
-
-
Save sramam/8056254 to your computer and use it in GitHub Desktop.
Python script that computes the git sha1 value, commandlinized
This file contains 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
def git_sha1(fname): | |
import hashlib | |
with open(fname, 'r') as f: | |
data = f.read() | |
sha1 = hashlib.sha1() | |
sha1.update("blob %d\0%s" % (len(data), data)) | |
return sha1.hexdigest() | |
if __name__ == "__main__": | |
import sys | |
fname = sys.argv[1] | |
print git_sha1(fname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment