Skip to content

Instantly share code, notes, and snippets.

@pgjones
Created March 3, 2016 21:59
Show Gist options
  • Save pgjones/6a8b1d21d19e064395d3 to your computer and use it in GitHub Desktop.
Save pgjones/6a8b1d21d19e064395d3 to your computer and use it in GitHub Desktop.
Pre push hook to prevent push of commits less than 30 mins old
#!/bin/bash
commit_timestamp=$(date -d @$(git log -n1 --format="%at") +%Y%m%d%H%M)
now=$(date +%s)
difference=($now - $commit_timestamp)
max=$((30 * 60))
if [ "$difference" -lt "$max" ]
then
echo "Too soon"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment