From 520443e05d06bfeff86043dc05ccdd0546c7ba09 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Mon, 26 Dec 2022 17:22:25 -0500 Subject: [PATCH] chore: issue162 - Enforce conventional commits and fix lintKotlin --- .githooks/commit-msg | 11 +++++++ .githooks/pre-commit | 30 +++++++++++++++++++ .githooks/pre-push | 10 +++++++ .../android/wisefy/sample/main/HomeScreen.kt | 1 - 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 .githooks/commit-msg create mode 100755 .githooks/pre-commit create mode 100755 .githooks/pre-push diff --git a/.githooks/commit-msg b/.githooks/commit-msg new file mode 100755 index 00000000..89aff81b --- /dev/null +++ b/.githooks/commit-msg @@ -0,0 +1,11 @@ +#!/bin/zsh + +if ! head -1 "$1" | grep -qE "^(feat|fix|ci|chore|docs|test|style|refactor|revert|perf)(\(.+?\))?: .{1,}$"; then + echo "Aborting commit. Your commit message is invalid." >&2 + exit 1 +fi + +if ! head -1 "$1" | grep -qE "^.{1,72}$"; then + echo "Aborting commit. Your commit message is too long." >&2 + exit 1 +fi diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..52fa70e7 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,30 @@ +#!/bin/zsh +echo "*******************************" +echo "Running git pre-commit hook" +echo "*******************************" + +echo "Running lintKotlin" +if ! lintKotlinStatus=$(./gradlew lintKotlin --parallel --max-workers=4); then + echo "lintKotlin must pass before commit!" + exit "$lintKotlinStatus" +fi + +echo "Running detekt" +if ! detektStatus=$(./gradlew detekt --parallel --max-workers=4); then + echo "detekt must pass before commit!" + exit "$detektStatus" +fi + +echo "Running lintDebug" +if ! lintDebugStatus=$(./gradlew lintDebug --parallel --max-workers=4); then + echo "lintDebug must pass before commit!" + exit "$lintDebugStatus" +fi + +echo "Running cpdCheck" +if ! cpdCheckStatus=$(./gradlew cpdCheck --parallel --max-workers=4); then + echo "cpdCheck must pass before commit!" + exit "$cpdCheckStatus" +fi + +echo "'Hard work pays off if you’re patient enough to see it through.' — Michael Chandler" diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 00000000..b5eee081 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,10 @@ +#!/bin/zsh +echo "*******************************" +echo "Running git pre-push hook" +echo "*******************************" + +# todo@patches Consider building and running unit tests here + +# todo@patches Consider building test APK for instrumentation here + +echo "'Do the hard jobs first. The easy jobs will take care of themselves.' — Dale Carnegie " diff --git a/app/src/main/java/com/isupatches/android/wisefy/sample/main/HomeScreen.kt b/app/src/main/java/com/isupatches/android/wisefy/sample/main/HomeScreen.kt index 6bab77f1..dfe36d3b 100644 --- a/app/src/main/java/com/isupatches/android/wisefy/sample/main/HomeScreen.kt +++ b/app/src/main/java/com/isupatches/android/wisefy/sample/main/HomeScreen.kt @@ -41,7 +41,6 @@ import com.isupatches.android.wisefy.sample.R import com.isupatches.android.wisefy.sample.ui.primitives.WisefySampleSizes import com.isupatches.android.wisefy.sample.ui.theme.WisefySampleTheme - @Composable internal fun HomeScreen() { WisefySampleTheme {