Files
AndroidJetpack/Kalendar/gradle/scripts/git-hooks.gradle.kts
T
coco 723ce1af5c a
2026-07-03 15:12:48 +08:00

34 lines
985 B
Kotlin

tasks {
register<Copy>("copyGitHooks") {
description = "Copies the git hooks from scripts/git-hooks to the .git folder."
group = "plugins.git-hook"
from("$rootDir/scripts/git-hooks/") {
include("**/*.sh")
rename("(.*).sh", "$1")
}
into("$rootDir/.git/hooks")
}
register<Exec>("installGitHooks") {
description = "Installs the scripts git hooks from scripts/git-hooks."
group = "plugins.git-hook"
workingDir(rootDir)
commandLine("chmod")
args("-R", "+x", ".git/hooks/")
dependsOn(named("copyGitHooks"))
doLast {
print("Git hooks installed successfully.")
}
}
register<Delete>("deleteGitHooks") {
description = "Delete the scripts git hooks."
group = "plugins.git-hook"
delete(fileTree(".git/hooks/"))
}
afterEvaluate {
tasks["clean"].dependsOn(tasks.named("installGitHooks"))
}
}