Skip to content

Commit 93886e4

Browse files
Merge pull request #36 from amingolmahalle/optimize/pre-commit
Update pre-commit hook to ignore build when cs files didn't change.
2 parents 88d518c + 90465c9 commit 93886e4

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

pre-commit

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
#!/bin/sh
22

3-
echo "dotnet build"
3+
exists=0
4+
echo "do a check for .cs files in change set"
5+
while read status file; do
6+
if [ "${file: -3}" == ".cs" ] ; then
7+
exists=1
8+
echo "find .cs file"
9+
break
10+
fi
11+
done <<<$(git diff --cached --name-status)
12+
13+
echo $exists
14+
if [[ $exists -eq 0 ]] ; then
15+
exit 0
16+
else
17+
echo "exists .cs file, so build the project"
18+
fi
419

20+
echo "dotnet build"
521
dotnet clean; dotnet build
622
rc=$?
723

@@ -20,4 +36,4 @@ if [[ $rc != 0 ]] ; then
2036
exit $rc
2137
fi
2238

23-
exit 0
39+
exit 0

0 commit comments

Comments
 (0)