Skip to content

Commit e06d734

Browse files
Add git pre commit hook (#57)
* feat: add pre commit hook * test: pre commit hook
1 parent 6243b01 commit e06d734

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

app/src/main/java/com/yogeshpaliyal/deepr/ui/components/EditDeeplinkDialog.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ fun EditDeeplinkDialog(
4141
link = it
4242
isError = false
4343
},
44-
label = { Text("Deeplink") },
44+
label = { Text("Deeplink")
45+
},
4546
isError = isError,
4647
supportingText = {
4748
if (isError) {

build.gradle.kts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,24 @@ plugins {
77
id("org.jmailen.kotlinter") version "5.2.0" apply false
88
}
99

10-
buildscript {
11-
dependencies {
12-
// classpath(libs.ktlint.compose)
13-
// classpath("io.nlopez.compose.rules:ktlint:0.4.27")
10+
tasks.register("copyGitHooks", Copy::class.java) {
11+
description = "Copies the git hooks from /git-hooks to the .git folder."
12+
group = "git hooks"
13+
from("$rootDir/scripts/pre-commit")
14+
into("$rootDir/.git/hooks/")
15+
}
16+
tasks.register("installGitHooks", Exec::class.java) {
17+
description = "Installs the pre-commit git hooks from /git-hooks."
18+
group = "git hooks"
19+
workingDir = rootDir
20+
commandLine = listOf("chmod")
21+
args("-R", "+x", ".git/hooks/")
22+
dependsOn("copyGitHooks")
23+
doLast {
24+
logger.info("Git hook installed successfully.")
1425
}
1526
}
27+
28+
afterEvaluate {
29+
tasks.getByPath(":app:preBuild").dependsOn(":installGitHooks")
30+
}

scripts/pre-commit

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
echo "
3+
===============
4+
| Running detekt...
5+
===============
6+
"
7+
8+
./gradlew --no-daemon --stacktrace :app:formatKotlin :app:lintKotlin
9+
10+
lintStatus=$?
11+
12+
# return 1 exit code if running checks fails
13+
[ $lintStatus -ne 0 ] && exit 1
14+
15+
exit 0

0 commit comments

Comments
 (0)