Last active
August 29, 2015 14:11
-
-
Save lamb-mei/7a64cd41475431e84169 to your computer and use it in GitHub Desktop.
Git Hook - Merge Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#---------------------------------------------------------- | |
# 檢查是否合併了 Enhancement,建立備份分支 | |
#---------------------------------------------------------- | |
# * Author: 羊小咩 Lamb-Mei | |
# * Update : 2014/12/20 | |
# * Description: 當合併了 Enhancement ,顯示警告跟建立備份用分支 | |
# | |
echo $GIT_REFLOG_ACTION | grep -q "merge Enhancement" >> /dev/null; | |
if [ $? == 0 ]; then | |
#已經合併了不想要的分支 | |
echo "Error 合併包含 Enhancement !!" | |
echo "請立即使用 reset 或 revert 解決此錯誤 !!" | |
#複製原始的狀態 | |
git branch AP_ISSUE_HEAD_bak HEAD^1 | |
git branch AP_ISSUE_Master_bak master^1 | |
else | |
echo "check OK 合併檢查無誤!!!" | |
fi | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#---------------------------------------------------------- | |
# 檢查是否包含 AP_ISSUE* 的分支,禁止 commit | |
#---------------------------------------------------------- | |
# * Author: 羊小咩 Lamb-Mei | |
# * Update : 2014/12/20 | |
# * Description: 含有 AP_ISSUE* 的分支 禁止 commit (為了提早發現問題) | |
# | |
git branch | grep "AP_ISSUE" >> /dev/null; | |
if [ $? == 0 ]; then | |
echo "您分支合併了 Enhancement ,請先解決此問題,能才進行後續動作!!" | |
exit 1 ; | |
else | |
exit 0 ; | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
#---------------------------------------------------------- | |
# 檢查是否包含 AP_ISSUE* 的分支,禁止 Push | |
#---------------------------------------------------------- | |
# * Author: 羊小咩 Lamb-Mei | |
# * Update : 2014/12/20 | |
# * Description: 含有 AP_ISSUE* 的分支 禁止 Push | |
# | |
git branch | grep "AP_ISSUE" >> /dev/null; | |
if [ $? == 0 ]; then | |
echo "您分支合併了 Enhancement ,請先解決此問題,能才進行後續動作!!" | |
exit 1 ; | |
else | |
exit 0 ; | |
fi | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
#---------------------------------------------------------- | |
# 禁止使用 Enhancement,進行 rebase | |
#---------------------------------------------------------- | |
# * Author: 羊小咩 Lamb-Mei | |
# * Update : 2014/12/20 | |
# * Description: 不允許 rebase onto Enhancement | |
# | |
echo $1 | grep -q "Enhancement" >> /dev/null; | |
if [ $? == 0 ]; then | |
#已經合併了不想要的分支 | |
echo "Error 不能使用 rebase onto Enhancement !!" | |
exit 1; | |
else | |
exit 0; | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment