I am working on having my post-commit hook change a file to have the commit number, so that my application can use that in error handling.
I was able to build the perl script to change the file, but I was wondering how to get the commit id from the hook. Currently my hook looks like this:
#!/bin/sh
#
# An example hook script that is called after a successful
# commit is made.
#
# To enable this hook, rename this file to "post-commit".
#: Nothing
perl -pi -e 's/[A-Za-z0-9+]$/commit-number/' ../../config/commit.git
I would like the commit-number to be some sort of variable holding the commit id.
Edit: I figured out that git rev-parse HEAD
will generate the HEAD commit which is what I need, but I don't know how to use that in the command.