-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit-hooks.gradle
29 lines (23 loc) · 903 Bytes
/
git-hooks.gradle
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
class GitHooksPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
def GIT_HOOKS_GROUP = 'Git Hooks'
def SCRIPT_ORIGIN_DIR = "${project.rootProject.rootDir}/scripts/git-hooks"
project.task('installGitHook', type: Copy) {
group = GIT_HOOKS_GROUP
description = "Installs the pre-commit git hooks from scripts/pre-commit."
from project.fileTree(SCRIPT_ORIGIN_DIR) {
include 'colors'
include 'pre-commit'
}
into { new File(project.rootProject.rootDir, '.git/hooks') }
fileMode 0777
}
project.task('deleteGitHooks', type: Delete) {
group = GIT_HOOKS_GROUP
description = "Delete the pre-commit git hooks."
delete(project.fileTree(".git/hooks/"))
}
}
}
apply plugin: GitHooksPlugin