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).

This commit is contained in:
Dawid Weiss 2020-01-27 20:47:02 +01:00
parent 7dc35e3a62
commit ff635cf701
1 changed files with 12 additions and 3 deletions

View File

@ -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}")
}
}
}
}