Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created April 6, 2018 17:47
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 havenwood/f5f2dbb69c2dd9008bba1f03cef03ca0 to your computer and use it in GitHub Desktop.
Save havenwood/f5f2dbb69c2dd9008bba1f03cef03ca0 to your computer and use it in GitHub Desktop.
git cat-file commit HEAD esque
timezone_offset=$(git log -1 --pretty="%ad" | grep -o "\S\+$")
parents=($(git log -n1 --pretty="%P" HEAD))
gpg_signature=$(git verify-commit HEAD 2>&1 | wc -c)
message=$(cat <<-END
tree $(git write-tree)
$(for parent in $parents; do; echo "parent $parent"; done)
author $(git log -1 --pretty="%an <%ae> %at") $timezone_offset
committer $(git log -1 --pretty="%cn <%ce> %ct") $timezone_offset
$(git log -1 --pretty="%B")
END
)
if (( $gpg_signature )); then
echo "\nerror: invalid - needs gpg signature" >&2
else
echo -n "$message"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment