Skip to content

Instantly share code, notes, and snippets.

@alepez
Created March 7, 2017 20:40
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 alepez/14d68e7f04ab43abbfaed4bf685ad351 to your computer and use it in GitHub Desktop.
Save alepez/14d68e7f04ab43abbfaed4bf685ad351 to your computer and use it in GitHub Desktop.
git hash hook c
#!/bin/bash
FILE="$( cd "${GIT_DIR}" && cd .. && pwd )/.gitversion.h"
echo '#ifndef GIT_VERSION' > "${FILE}"
echo -n '#define GIT_VERSION "' >> "${FILE}"
git rev-parse HEAD | tr -d '\n' >> "${FILE}"
echo '"' >> "${FILE}"
echo '#endif' >> "${FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment