This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
git_hooks [2017/10/19 08:40] – admin | git_hooks [2017/11/28 21:13] – admin | ||
---|---|---|---|
Line 52: | Line 52: | ||
done | done | ||
fi | fi | ||
+ | </ | ||
+ | |||
+ | |||
+ | Another Version | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/sh | ||
+ | |||
+ | read oldrev newrev refname protocol | ||
+ | |||
+ | #### http:// | ||
+ | |||
+ | merges=`git diff --name-only --stat $oldrev..$newrev` | ||
+ | |||
+ | for changed_file in `echo $merges`; do | ||
+ | |||
+ | REGEX_MERGE_DEVELOP=" | ||
+ | |||
+ | # If $changed_file matches regex $REGEX_MERGE_DEVELOP | ||
+ | if [[ $changed_file =~ $REGEX_MERGE_DEVELOP ]]; | ||
+ | then | ||
+ | | ||
+ | # MERGE_PREVENT_BRANCH=$(echo $changed_file | tr " | ||
+ | MERGE_PREVENT_BRANCH=$(echo $changed_file | tr " | ||
+ | MERGE_TO_BRANCH=$(echo $refname | tr "/" | ||
+ | | ||
+ | if [[ " | ||
+ | then | ||
+ | | ||
+ | echo -e " | ||
+ | echo -e " | ||
+ | echo -e " | ||
+ | echo -e "This file prevents merging: $changed_file \e[0m" | ||
+ | echo -e "FIX IT: git reset HEAD $changed_file" | ||
+ | echo -e "" | ||
+ | echo -e " | ||
+ | exit 1 | ||
+ | fi | ||
+ | else | ||
+ | exit 0 | ||
+ | fi | ||
+ | done | ||
+ | |||
</ | </ |