forked from mobilejazz/harmony-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-hooks.gradle.kts
33 lines (30 loc) · 895 Bytes
/
git-hooks.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
tasks {
register<Copy>("copyGitHooks") {
description = "Copies the git hooks from scripts/git-hooks to the .git folder."
group = "git hooks"
from("$rootDir/scripts/git-hooks/") {
include("**/*.sh")
rename("(.*).sh", "$1")
}
into("$rootDir/.git/hooks")
}
register<Exec>("installGitHooks") {
description = "Installs the pre-commit git hooks from scripts/git-hooks."
group = "git hooks"
workingDir(rootDir)
commandLine("chmod")
args("-R", "+x", "$rootDir/.git/hooks/")
dependsOn(named("copyGitHooks"))
doLast {
logger.info("Git hooks installed successfully.")
}
}
register<Delete>("deleteGitHooks") {
description = "Delete the pre-commit git hooks."
group = "git hooks"
delete(fileTree("$rootDir/.git/hooks/"))
}
afterEvaluate {
tasks["assemble"].dependsOn(tasks.named("installGitHooks"))
}
}