Skip to content

Instantly share code, notes, and snippets.

@whitered
Created August 6, 2010 13:03
Show Gist options
  • Save whitered/511290 to your computer and use it in GitHub Desktop.
Save whitered/511290 to your computer and use it in GitHub Desktop.
Lucky commit git post-commit hook. Checks your last commit SHA number if it is lucky one (the sum of first 20 digits equals to the sum of last 20 ones).
#!/bin/sh
left_sum=$((`git log -1 --format=format:%H | cut -c -20 | sed -e 's/[a-f0-9]/\+0x&/g'`))
right_sum=$((`git log -1 --format=format:%H | cut -c 21- | sed -e 's/[a-f0-9]/\+0x&/g'`))
if [ $left_sum = $right_sum ]; then
echo '****************************************'
echo '* Congratulations! Lucky commit!!! *'
echo '****************************************'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment