Skip to content

Instantly share code, notes, and snippets.

@ryanbillingsley
Last active January 4, 2016 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbillingsley/8588542 to your computer and use it in GitHub Desktop.
Save ryanbillingsley/8588542 to your computer and use it in GitHub Desktop.
def building_commit
i = 0
body = "tree #{@tree}
parent #{@parent}
author CTF user <me@example.com> #{@timestamp} +0000
committer CTF user <me@example.com> #{@timestamp} +0000
Give me a Gitcoin #{i}"
header = "commit #{body.length}\0"
store = header + body
sha1 = Digest::SHA1.hexdigest(store)
sha1
end
def git_commit
i = 0
body = "tree #{@tree}
parent #{@parent}
author CTF user <me@example.com> #{@timestamp} +0000
committer CTF user <me@example.com> #{@timestamp} +0000
Give me a Gitcoin #{i}"
sha1 = `git hash-object -t commit --stdin <<< "#{body}"`
sha1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment