Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94eeef18 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

chore: add pre-push githook via gradle

parent 458fcc5e
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -46,3 +46,19 @@ tasks.register('clean', Delete) {
    delete rootProject.buildDir
}

tasks.register('installGitHooks', Copy) {
    description = 'Installs git hooks from scripts/hooks into .git/hooks'
    group = 'setup'

    from("${rootProject.rootDir}/scripts/hooks")
    into("${rootProject.rootDir}/.git/hooks")
    fileMode = 0755
}

gradle.projectsEvaluated {
    subprojects {
        tasks.matching { it.name == 'preBuild' }.configureEach {
            dependsOn rootProject.tasks.named('installGitHooks')
        }
    }
}

scripts/hooks/pre-push

0 → 100644
+21 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
echo "🔍 Running Detekt..."
./gradlew detekt
DETEKT_EXIT=$?

if [ $DETEKT_EXIT -ne 0 ]; then
  echo "❌ Push rejected: fix Detekt issues before pushing."
  exit 1
fi

echo "🔍 Running Lint..."
./gradlew lintRelease
LINT_EXIT=$?

if [ $LINT_EXIT -ne 0 ]; then
  echo "❌ Push rejected: fix Lint issues before pushing."
  exit 1
fi

echo "✅ All checks passed!"
exit 0