Apache Lucene open-source search software
LUCENE-9184, LUCENE-9183: allow skipping git status check in precommit with -Pvalidation.git.failOnModified=false (or place this in gradle.properties to make it permanent).
Dawid Weissff635cf701f0
diff --git a/gradle/validation/git-status.gradle b/gradle/validation/git-status.gradleindex 2122b785281..ea4ae632b86 100644--- a/gradle/validation/git-status.gradle+++ b/gradle/validation/git-status.gradle@@ -15,8 +15,7 @@* limitations under the License.*/-// This adds top-level 'precommit' task with essential-// precommit validation checks.+// This verifies local git repository's status.import org.eclipse.jgit.api.*;import org.eclipse.jgit.storage.file.FileRepositoryBuilder;@@ -73,7 +72,17 @@ configure(rootProject) {}.sort()if (offenders) {- throw new GradleException("Working copy is not a clean git checkout, offending files:\n${offenders.join("\n")}")+ def checkProp = "validation.git.failOnModified"+ def shouldFail = Boolean.valueOf(propertyOrDefault(checkProp, true))+ def message = "Working copy is not a clean git checkout" ++ (shouldFail ? " (skip with -P${checkProp}=false)" : "") ++ ", offending files:\n${offenders.join("\n")}"++ if (shouldFail) {+ throw new GradleException(message)+ } else {+ logger.lifecycle("NOTE: ${message}")+ }}}}