forked from AgoraIO/API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·38 lines (32 loc) · 1.03 KB
/
pre-commit
File metadata and controls
executable file
·38 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
SCRIPT_DIR=$(dirname "$0")
SCRIPT_ABS_PATH=`cd "$SCRIPT_DIR"; pwd`
ANDROID_DIFF_FILES=`git diff --cached --name-only --diff-filter=ACM -- '*' | grep 'Android'`
if [[ "$ANDROID_DIFF_FILES" != "" ]]
then
cd Android/APIExample
echo "precommit >> current paht = $(pwd), diff files = $ANDROID_DIFF_FILES"
./gradlew -Dorg.gradle.project.commit_diff_files="$ANDROID_DIFF_FILES" checkstyle detekt
if [ $? -eq 0 ]; then
echo "precommit >> checkstyle detekt OK."
else
echo "precommit >> checkstyle detekt Failed."
exit 1
fi
else
echo "precommit >> No changing android files."
fi