diff --git a/hooks/pre-commit-checkstyle b/hooks/pre-commit-checkstyle index 1ee281e..eed8285 100755 --- a/hooks/pre-commit-checkstyle +++ b/hooks/pre-commit-checkstyle @@ -5,6 +5,16 @@ if [[ "true" != "$checkstyle_enabled" ]]; then exit 0 fi +checkstyle_language="`git config --get diff-check.checkstyle.language`" +if [ ! -n "$checkstyle_language" ]; then + checkstyle_language="`git config --get diff-check.language`" +fi +if [ -n "$checkstyle_language" ]; then + checkstyle_language=" -Duser.language=$checkstyle_language " +else + checkstyle_langauge="" +fi + GIT_ROOT_DIR=`git rev-parse --show-toplevel` GIT_HOOK_DIR=`git config --get core.hooksPath` if [ ! -d "${GIT_HOOK_DIR}" ]; then @@ -33,7 +43,7 @@ if [ -z "$checkstyle_config_file" -o ! -f "$checkstyle_config_file" ]; then fi echo "Check Style" -java -jar ${GIT_HOOK_DIR}/diff-checkstyle.jar -c $checkstyle_config_file --git-dir ${GIT_ROOT_DIR} --include-staged-codes $exclude_regexp_opt +java $checkstyle_language -jar ${GIT_HOOK_DIR}/diff-checkstyle.jar -c $checkstyle_config_file --git-dir ${GIT_ROOT_DIR} --include-staged-codes $exclude_regexp_opt result=$? if [ $result -ne 0 ]; then echo "Please fix the checkstyle problems before submit the commit!" diff --git a/hooks/pre-commit-pmd b/hooks/pre-commit-pmd index 04ca765..1bf58b9 100755 --- a/hooks/pre-commit-pmd +++ b/hooks/pre-commit-pmd @@ -5,6 +5,17 @@ if [[ "true" != "$pmd_enabled" ]]; then exit 0 fi +pmd_language="`git config --get diff-check.pmd.language`" +if [ ! -n "$pmd_language" ]; then + pmd_language="`git config --get diff-check.language`" +fi +if [ -n "$pmd_language" ]; then + pmd_language=" -Dpmd.language=$pmd_language " +else + pmd_language="" +fi + + GIT_ROOT_DIR=`git rev-parse --show-toplevel` GIT_HOOK_DIR=`git config --get core.hooksPath` if [ ! -d "${GIT_HOOK_DIR}" ]; then @@ -34,7 +45,7 @@ if [ -z "$pmd_rulesets" ]; then pmd_rulesets="rulesets/java/ali-all.xml" fi echo "PMD Check" -java -jar ${GIT_HOOK_DIR}/diff-pmd.jar -R $pmd_rulesets -f diff-text -git-dir ${GIT_ROOT_DIR} -include-staged-codes $exclude_regexp_opt +java $pmd_language -jar ${GIT_HOOK_DIR}/diff-pmd.jar -R $pmd_rulesets -f diff-text -git-dir ${GIT_ROOT_DIR} -include-staged-codes $exclude_regexp_opt result=$? if [ $result -ne 0 ]; then echo "Please fix the pmd problems before submit the commit!"