diff --git a/build.gradle.kts b/build.gradle.kts index 4e94a1381..ca81a3da1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -36,6 +36,16 @@ allprojects { apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "org.jlleitschuh.gradle.ktlint") + ktlint { + ignoreFailures = true + // Hvis du gjør endringer i disse filterne må du slette alle "build"/"out"-mappene og deretter + // kjøre ./gradlew --no-build-cache ktlintCheck minst én gang for at endringene skal ta effekt + filter { + exclude { it.file.path.contains("generated") } + exclude { it.file.path.contains("test") } + } + } + dependencies { implementation("com.github.navikt:rapids-and-rivers:$rapidsAndRiversVersion") implementation("io.ktor:ktor-server-cio:$ktorVersion") @@ -89,15 +99,6 @@ allprojects { } testImplementation("io.mockk:mockk:$mockkVersion") } - - ktlint { - // Hvis du gjør endringer i disse filterne må du slette alle "build"/"out"-mappene og deretter - // kjøre ./gradlew --no-build-cache ktlintCheck minst én gang for at endringene skal ta effekt - filter { - exclude { it.file.path.contains("generated") } - exclude { it.file.path.contains("test") } - } - } } subprojects { diff --git a/scripts/pre-commit b/scripts/pre-commit deleted file mode 100755 index 1c78fb31b..000000000 --- a/scripts/pre-commit +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -######## KTLINT-GRADLE HOOK START ######## - -CHANGED_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $NF ~ /\.kts?$/ { print $NF }')" - -if [ -z "$CHANGED_FILES" ]; then - echo "No Kotlin staged files." - exit 0 -fi; - -echo "Running ktlint over these files:" -echo "$CHANGED_FILES" - -diff=.git/unstaged-ktlint-git-hook.diff -git diff --color=never > $diff -if [ -s $diff ]; then - git apply -R $diff -fi - -./gradlew --quiet ktlintFormat -PinternalKtlintGitFilter="$CHANGED_FILES" -gradle_command_exit_code=$? - -echo "Completed ktlint run." - -echo "$CHANGED_FILES" | while read -r file; do - if [ -f $file ]; then - git add $file - fi -done - - -if [ -s $diff ]; then - git apply --ignore-whitespace $diff -fi -rm $diff -unset diff - -echo "Completed ktlint hook." -exit $gradle_command_exit_code -######## KTLINT-GRADLE HOOK END ########