From 6c1b2cb7a5d16c0b4124c7eff4d5074de0508157 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Jan 2020 12:37:53 +0300 Subject: [PATCH 1/3] Added android_hooks folder and gradle task to copy build scripts hooks to project hooks --- gradle/installGitHooks.gradle | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 gradle/installGitHooks.gradle 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 From 4206cba09953f8ddc50a1b08317c873505c7264a Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Jan 2020 12:39:51 +0300 Subject: [PATCH 2/3] added pre-push hook --- android_hooks/pre-push | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 android_hooks/pre-push diff --git a/android_hooks/pre-push b/android_hooks/pre-push new file mode 100755 index 0000000..fc221d2 --- /dev/null +++ b/android_hooks/pre-push @@ -0,0 +1,21 @@ +#!/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 From 86d0c8c661cc8eddde96c589dbe7f045d328af09 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Jan 2020 12:41:41 +0300 Subject: [PATCH 3/3] superfluous line removed --- android_hooks/pre-push | 1 - 1 file changed, 1 deletion(-) diff --git a/android_hooks/pre-push b/android_hooks/pre-push index fc221d2..cc5cdce 100755 --- a/android_hooks/pre-push +++ b/android_hooks/pre-push @@ -4,7 +4,6 @@ echo "Pre push static analysis" output=$(./gradlew staticAnalysis --daemon 2>&1) - status=$? if [ "$status" = 0 ] ; then