Skip to content

Instantly share code, notes, and snippets.

@hSATAC
Created December 16, 2011 02:12
Show Gist options
  • Save hSATAC/1484109 to your computer and use it in GitHub Desktop.
Save hSATAC/1484109 to your computer and use it in GitHub Desktop.
#!/bin/sh
# place in {repo}/.git/hooks/update
# chmod +x update
name="$1"
old="$2"
new="$3"
user_name=$(git log -1 --pretty=format:%aN $new)
#branch=$(git rev-parse --symbolic --abbrev-ref $1)
branch=${name#refs/heads/}
if [ "$branch" == "master" ] || [ "$branch" == "staging" ]
then
if [ "$user_name" != "Kevin Luo" ]
then
echo "Username $user_name has no premission to commit branch [$branch]!"
exit 43
else
exit 0
fi
fi
@hSATAC
Copy link
Author

hSATAC commented Dec 29, 2011

後來想到這個 script 邏輯錯誤了
他檢查的是 commit 的 author 而不是 pusher
在一般 git 環境似乎沒辦法抓到 pusher...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment