Commit 1296dbc3 authored by Soraphis's avatar Soraphis
Browse files

updated git hooks

parent 29dee7bd
#!/bin/sh #!/bin/sh
ASSETS_DIR="$(git config --get unity3d.assets-dir || echo "Assets")"
# Remove empty assets directory # Remove empty assets directory
find "$ASSETS_DIR" -depth -type d -empty -delete find Assets -type d -empty -prune -exec rm -rf {} \;
\ No newline at end of file
#!/bin/sh #!/bin/sh
ASSETS_DIR="$(git config --get unity3d.assets-dir || echo "Assets")" command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-merge.\n"; exit 2; }
git lfs post-merge "$@"
# Remove empty assets directory # Remove empty assets directory
find "$ASSETS_DIR" -depth -type d -empty -delete find Assets -type d -empty -prune -exec rm -rf {} \;
\ No newline at end of file
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
# #
# To enable this hook, rename this file to "pre-commit". # To enable this hook, rename this file to "pre-commit".
ASSETS_DIR="$(git config --get unity3d.assets-dir || echo "Assets")"
if git rev-parse --verify HEAD >/dev/null 2>&1 if git rev-parse --verify HEAD >/dev/null 2>&1
then then
against=HEAD against=HEAD
...@@ -20,7 +18,7 @@ fi ...@@ -20,7 +18,7 @@ fi
# Redirect output to stderr. # Redirect output to stderr.
exec 1>&2 exec 1>&2
git diff --cached --name-only --diff-filter=A -z $against -- "$ASSETS_DIR" | while read -d $'\0' f; do git diff --cached --name-only --diff-filter=A -z $against -- Assets | while read -d $'\0' f; do
ext="${f##*.}" ext="${f##*.}"
base="${f%.*}" base="${f%.*}"
...@@ -28,22 +26,18 @@ git diff --cached --name-only --diff-filter=A -z $against -- "$ASSETS_DIR" | whi ...@@ -28,22 +26,18 @@ git diff --cached --name-only --diff-filter=A -z $against -- "$ASSETS_DIR" | whi
if [ $(git ls-files --cached -- "$base" | wc -l) = 0 ]; then if [ $(git ls-files --cached -- "$base" | wc -l) = 0 ]; then
cat <<EOF cat <<EOF
Error: Redudant meta file. Error: Redudant meta file.
Meta file \`$f' is added, but \`$base' is not in the git index. Meta file \`$f' is added, but \`$base' is not in the git index.
Please add \`$base' to git as well. Please add \`$base' to git as well.
EOF EOF
exit 1 exit 1
fi fi
else else
p="$f" p="$f"
while [ "$p" != "$ASSETS_DIR" ]; do while [ "$p" != "Assets" ]; do
if [ $(git ls-files --cached -- "$p.meta" | wc -l) = 0 ]; then if [ $(git ls-files --cached -- "$p.meta" | wc -l) = 0 ]; then
cat <<EOF cat <<EOF
Error: Missing meta file. Error: Missing meta file.
Asset \`$f' is added, but \`$p.meta' is not in the git index. Asset \`$f' is added, but \`$p.meta' is not in the git index.
Please add \`$p.meta' to git as well. Please add \`$p.meta' to git as well.
EOF EOF
exit 1 exit 1
...@@ -58,7 +52,7 @@ if [ "$ret" != 0 ]; then ...@@ -58,7 +52,7 @@ if [ "$ret" != 0 ]; then
exit "$ret" exit "$ret"
fi fi
git diff --cached --name-only --diff-filter=D -z $against -- "$ASSETS_DIR" | while read -d $'\0' f; do git diff --cached --name-only --diff-filter=D -z $against -- Assets | while read -d $'\0' f; do
ext="${f##*.}" ext="${f##*.}"
base="${f%.*}" base="${f%.*}"
...@@ -66,22 +60,18 @@ git diff --cached --name-only --diff-filter=D -z $against -- "$ASSETS_DIR" | whi ...@@ -66,22 +60,18 @@ git diff --cached --name-only --diff-filter=D -z $against -- "$ASSETS_DIR" | whi
if [ $(git ls-files --cached -- "$base" | wc -l) != 0 ]; then if [ $(git ls-files --cached -- "$base" | wc -l) != 0 ]; then
cat <<EOF cat <<EOF
Error: Redudant meta file. Error: Redudant meta file.
Meta file \`$f' is removed, but \`$base' is still in the git index. Meta file \`$f' is removed, but \`$base' is still in the git index.
Please remove \`$base' from git as well. Please remove \`$base' from git as well.
EOF EOF
exit 1 exit 1
fi fi
else else
p="$f" p="$f"
while [ "$p" != "$ASSETS_DIR" ]; do while [ "$p" != "Assets" ]; do
if [ $(git ls-files --cached -- "$p" | wc -l) = 0 ] && [ $(git ls-files --cached -- "$p.meta" | wc -l) != 0 ]; then if [ $(git ls-files --cached -- "$p" | wc -l) = 0 ] && [ $(git ls-files --cached -- "$p.meta" | wc -l) != 0 ]; then
cat <<EOF cat <<EOF
Error: Missing meta file. Error: Missing meta file.
Asset \`$f' is removed, but \`$p.meta' is still in the git index. Asset \`$f' is removed, but \`$p.meta' is still in the git index.
Please remove \`$p.meta' from git as well. Please remove \`$p.meta' from git as well.
EOF EOF
exit 1 exit 1
...@@ -94,4 +84,4 @@ done ...@@ -94,4 +84,4 @@ done
ret="$?" ret="$?"
if [ "$ret" != 0 ]; then if [ "$ret" != 0 ]; then
exit "$ret" exit "$ret"
fi fi
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment