-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.gradle.kts
25 lines (22 loc) · 1013 Bytes
/
init.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
// This script runs during Gradle initialization
gradle.projectsLoaded {
rootProject.afterEvaluate {
// Check if .git directory exists (we're in a Git repo)
if (file(".git").exists()) {
// Create .githooks directory if it doesn't exist
file(".githooks").mkdirs()
// Copy the pre-commit hook if it exists
val preCommitHook = file(".githooks/pre-commit")
if (preCommitHook.exists()) {
// Copy hook to .git/hooks
file(".git/hooks").mkdirs()
preCommitHook.copyTo(file(".git/hooks/pre-commit"), overwrite = true)
// Make the hook executable on Unix-like systems
if (!System.getProperty("os.name").lowercase().contains("windows")) {
Runtime.getRuntime().exec("chmod +x ${file(".git/hooks/pre-commit").absolutePath}")
}
println("Git pre-commit hook installed successfully")
}
}
}
}