mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
27 lines
773 B
Groovy
27 lines
773 B
Groovy
static def isLinuxOrMacOs() {
|
|
def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
|
|
return osName.contains('linux') || osName.contains('mac os') || osName.contains('macos')
|
|
}
|
|
|
|
task copyGitHooks(type: Copy) {
|
|
description 'Copies the git hooks from team-props/git-hooks to the .git folder.'
|
|
from("${rootDir}/team-props/git-hooks/") {
|
|
include '**/*.sh'
|
|
rename '(.*).sh', '$1'
|
|
}
|
|
into "${rootDir}/.git/hooks"
|
|
}
|
|
|
|
task installGitHooks(type: Exec) {
|
|
description 'Installs the pre-commit git hooks from team-props/git-hooks.'
|
|
group 'git hooks'
|
|
workingDir rootDir
|
|
commandLine 'chmod'
|
|
args '-R', '+x', '.git/hooks/'
|
|
onlyIf { isLinuxOrMacOs() }
|
|
dependsOn copyGitHooks
|
|
doLast {
|
|
logger.info('Git hook installed successfully.')
|
|
}
|
|
}
|