Skip to content

Instantly share code, notes, and snippets.

@jindaxia
Last active September 2, 2021 03:30
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 jindaxia/79e5edeca0b50c2aab5bc696af9996bc to your computer and use it in GitHub Desktop.
Save jindaxia/79e5edeca0b50c2aab5bc696af9996bc to your computer and use it in GitHub Desktop.
Used git hooks
#!/bin/sh
#
# An example hook script to update current push setting for code reviewing.
current_branch=$(git name-rev --name-only HEAD)
config_push="HEAD:refs/for/"$current_branch
# Current remote branch
current_remote=$(git config branch.$current_branch.remote)
if [ ! $current_remote ]; then
echo "The current branch $current_branch has no upstream branch."
echo "To set a upstream branch use:"
echo " git branch -u origin/"$current_branch
exec `git config --remove-section remote.review`
else
remote_repo=$(git config remote.$current_remote.url)
echo "current branch push review command is:"
echo "git push "$remote_repo $config_push
exec `git config remote.review.pushurl "$remote_repo"`
exec `git config remote.review.push $config_push`
fi
#!/bin/sh
# author: xxx
# 检查提交代码使用的邮箱,规定必须使用公司邮箱提交代码
EMAIL=$(git config user.email)
if [[ ! $EMAIL =~ ^[.[:alnum:]]+@cmss\.xxx\.com$ ]] &&
[[ ! $EMAIL =~ ^[.[:alnum:]]+ext_@cop\.xxx\.com\.cn$ ]];
then
echo "Your git information is not valid";
echo "Please run:"
echo ' git config --local user.name "<Your name in xxxx>"'
echo ' git config --local user.email "<Your alias>@cmss.xxx.com or cop.xxx.com.cn"'
exit 1;
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment