Skip to content

Instantly share code, notes, and snippets.

@hnq90
Created April 25, 2019 10:18
Show Gist options
  • Save hnq90/8d6043390ce2a74a1c1222210f7ca502 to your computer and use it in GitHub Desktop.
Save hnq90/8d6043390ce2a74a1c1222210f7ca502 to your computer and use it in GitHub Desktop.
Rikkeisoft GitHub Pre-Push Hook
#!/bin/bash
# HOW TO USE: Copy this file to `.git/hooks` in your project directory.
remote_url="$2"
warning="[Warning] Don't push the project' source code to GitHub unless you are allowed."
policy_url="Rikkeisoft's IPR Regulation: https://rikkei.vn/help/view/97"
prompt_user() {
echo $warning
echo $policy_url
read -n1 -p "Do you want to CONTINUE pushing? [Y/n]" answer < /dev/tty
echo
echo $answer
if [[ $answer == 'Y' ]]; then
exit 0
fi
exit 1
}
if [[ $remote_url =~ 'github.com' ]]; then
prompt_user
fi
unset prompt_user
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment