Created
July 29, 2017 11:22
-
-
Save sanukin39/2a5aaafee2008100e5e14c528a86bd68 to your computer and use it in GitHub Desktop.
git pre-commit for unity and it check forgot to add the meta file
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 | |
# | |
# git pre-commit for Unity | |
# It check Forgot to add the meta file | |
# An alert is issued when a file has been added but no meta file has been added | |
# | |
# To enable this hook, rename this file to "pre-commit". | |
addfiles=`git diff --cached --name-status | awk '$2 != "A" { print $2 }'` | |
for file in $addfiles | |
do | |
if [[ ! "$file" =~ .meta$ ]]; then | |
metaFileName=$file.meta | |
hasMeta=false | |
for item in ${addfiles[@]}; do | |
if [ $item == $metaFileName ]; then | |
hasMeta=true | |
fi | |
done | |
if ! $hasMeta ; then | |
cat <<EOF | |
The following file was added, but the meta file for the file was not added | |
Check your git workspace!! | |
${file} | |
EOF | |
exit 1 | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment