diff --git a/android_hooks/pre-push b/android_hooks/pre-push new file mode 100755 index 0000000..cc5cdce --- /dev/null +++ b/android_hooks/pre-push @@ -0,0 +1,20 @@ +#!/bin/sh + +echo "Pre push static analysis" + +output=$(./gradlew staticAnalysis --daemon 2>&1) + +status=$? + +if [ "$status" = 0 ] ; then + exit 0 +else + build_date=$(date +'%Y-%m-%d_%T') + file_name="build_$build_date" + folder_name="./build_log/" + file_path="${folder_name}${file_name}" + mkdir -p "$folder_name" + echo "$output" >> "$file_path" + echo "Pre push static failed. Full log path: ${file_path}" + exit 1 +fi diff --git a/gradle/installGitHooks.gradle b/gradle/installGitHooks.gradle new file mode 100644 index 0000000..8f1ebc4 --- /dev/null +++ b/gradle/installGitHooks.gradle @@ -0,0 +1,7 @@ +task installGitHooks(type: Copy) { + from new File(buildScriptsDir, 'android_hooks') + into { new File(rootProject.rootDir, '.git/hooks') } + fileMode 0777 +} + +tasks.getByPath(':app:preBuild').dependsOn installGitHooks