Skip to content

Commit 46aa368

Browse files
lehvolkDanySK
authored andcommittedDec 9, 2022
feat: add api for configuring commit-hooks based on file
1 parent 5592764 commit 46aa368

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ either requiring their success or not, through `tasks`
8787
gitHooks {
8888
path = "some/folder" // custom git repository location, defaults to the local project and scans the parents
8989
preCommit {
90-
// Script downloaded from a source, can be a String or URL
90+
// Script from a source, can be a String, URL or File
9191
from("https://my.repo/pre-commit.sh")
9292
// Content can be added at the bottom of the script
9393
appendScript {

‎src/main/kotlin/org/danilopianini/gradle/git/hooks/ScriptContext.kt

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.danilopianini.gradle.git.hooks
22

33
import org.gradle.api.Task
44
import org.gradle.api.tasks.TaskProvider
5+
import java.io.File
56
import java.net.URL
67

78
/**
@@ -24,6 +25,11 @@ interface ScriptContext {
2425
*/
2526
fun appendScript(script: () -> String)
2627

28+
/**
29+
* Generates a script from the provided [file].
30+
*/
31+
fun from(file: File) = from("") { file.readText() }
32+
2733
/**
2834
* Generates a script from the provided [url].
2935
*/

0 commit comments

Comments
 (0)
Please sign in to comment.