Created
November 9, 2021 03:32
-
-
Save abiriadev/d6888f908a97fa28a959c815ad2ec5e1 to your computer and use it in GitHub Desktop.
converts plain text to a git object
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
#!/usr/bin/ruby | |
require 'digest/sha1' | |
require 'zlib' | |
content = gets | |
print "type? (blob): " | |
type = gets | |
if type == "" then type = "blob" end | |
header = "blob #{content.length}\0" | |
store = header + content | |
# puts "<#{store}>" | |
sha1 = Digest::SHA1.hexdigest(store) | |
puts sha1 | |
zlib_content = Zlib::Deflate.deflate(store) | |
puts zlib_content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this script referred to chapter 10 of pro git