Skip to content

Commit 8944e01

Browse files
committed
feat: git config unity3d.assets-dir
1 parent ae6f27c commit 8944e01

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

‎README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,11 @@ a team is collaborating on the same code base.
2424
Copy files `post-checkout``post-merge` and `pre-commit` to .git/hooks in your
2525
git repository. If you also have hooks defined in these files, append them to
2626
existing files.
27+
28+
It is assumed that Assets directory is located in the root directory of the
29+
repository. It can be configured using git config. Following example tells the
30+
scripts that the assets directory is `client/Assets`.
31+
32+
```
33+
git config unity3d.assets-dir client/Assets
34+
```

‎scripts/post-checkout‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22

3+
ASSETS_DIR="$(git config --get unity3d.assets-dir ||echo"Assets")"
34
# Remove empty assets directory
4-
find Assets -depth -type d -empty -delete
5+
find "$ASSETS_DIR" -depth -type d -empty -delete

‎scripts/post-merge‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22

3+
ASSETS_DIR="$(git config --get unity3d.assets-dir ||echo"Assets")"
34
# Remove empty assets directory
4-
find Assets -depth -type d -empty -delete
5+
find "$ASSETS_DIR" -depth -type d -empty -delete

‎scripts/pre-commit‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#
88
# To enable this hook, rename this file to "pre-commit".
99

10+
ASSETS_DIR="$(git config --get unity3d.assets-dir ||echo"Assets")"
11+
1012
if git rev-parse --verify HEAD >/dev/null 2>&1
1113
then
1214
against=HEAD
@@ -18,7 +20,7 @@ fi
1820
# Redirect output to stderr.
1921
exec1>&2
2022

21-
git diff --cached --name-only --diff-filter=A -z $against -- Assets|whileread -d $'\0' f;do
23+
git diff --cached --name-only --diff-filter=A -z $against -- "$ASSETS_DIR"|whileread -d $'\0' f;do
2224
ext="${f##*.}"
2325
base="${f%.*}"
2426

@@ -35,7 +37,7 @@ EOF
3537
fi
3638
else
3739
p="$f"
38-
while [ "$p"!="Assets" ];do
40+
while [ "$p"!="$ASSETS_DIR" ];do
3941
if [ $(git ls-files --cached -- "$p.meta"| wc -l)= 0 ];then
4042
cat <<EOF
4143
Error: Missing meta file.
@@ -56,7 +58,7 @@ if [ "$ret" != 0 ]; then
5658
exit"$ret"
5759
fi
5860

59-
git diff --cached --name-only --diff-filter=D -z $against -- Assets|whileread -d $'\0' f;do
61+
git diff --cached --name-only --diff-filter=D -z $against -- "$ASSETS_DIR"|whileread -d $'\0' f;do
6062
ext="${f##*.}"
6163
base="${f%.*}"
6264

@@ -73,7 +75,7 @@ EOF
7375
fi
7476
else
7577
p="$f"
76-
while [ "$p"!="Assets" ];do
78+
while [ "$p"!="$ASSETS_DIR" ];do
7779
if [ $(git ls-files --cached -- "$p"| wc -l)= 0 ] && [ $(git ls-files --cached -- "$p.meta"| wc -l)!= 0 ];then
7880
cat <<EOF
7981
Error: Missing meta file.

0 commit comments

Comments
(0)