Apache Solr open-source search software
build: support running in a git worktree (RAT, git-status) (#5165)
David Smiley681f8b208ffb
diff --git a/gradle/validation/git-status.gradle b/gradle/validation/git-status.gradleindex 17fa3527511..3dc28394019 100644--- a/gradle/validation/git-status.gradle+++ b/gradle/validation/git-status.gradle@@ -41,6 +41,7 @@ configure(rootProject) {doFirst {try {def repository = new FileRepositoryBuilder()+ .findGitDir(rootProject.projectDir).setWorkTree(rootProject.projectDir).setMustExist(true).build()@@ -65,6 +66,7 @@ configure(rootProject) {def statustry {def repository = new FileRepositoryBuilder()+ .findGitDir(rootProject.projectDir).setWorkTree(rootProject.projectDir).setMustExist(true).build()@@ -73,15 +75,9 @@ configure(rootProject) {status = null}if (status == null) {- if (file("${rootProject.projectDir}/.git").exists()) {- // Ignore git worktree branches until jgit supports them.- logger- .warn("WARNING: git worktrees are not supported by jgit (won't check dirty files): ${rootProject.projectDir}")- } else {- // Ignore the check. This isn't a git checkout.- logger- .warn("WARNING: Directory is not a valid git checkout (won't check dirty files): ${rootProject.projectDir}")- }+ // Ignore the check. This isn't a git checkout.+ logger+ .warn("WARNING: Directory is not a valid git checkout (won't check dirty files): ${rootProject.projectDir}")} else {// git ignores any folders which are empty (this includes folders with recursively empty sub-folders).def untrackedNonEmptyFolders = status.untrackedFolders.findAll {path ->diff --git a/gradle/validation/rat-sources.gradle b/gradle/validation/rat-sources.gradleindex 6b256f40044..181c6bd7eb9 100644--- a/gradle/validation/rat-sources.gradle+++ b/gradle/validation/rat-sources.gradle@@ -51,14 +51,16 @@ Set<String> loadGitTrackedFiles() {rootProject.ext.ratGitIndexLoaded = truerootProject.ext.ratGitTrackedFiles = null+ // .git is a file (not a directory) in a git worktreedef dotGit = new File(rootProject.projectDir, ".git")- if (!dotGit.isDirectory()) {+ if (!dotGit.exists()) {return null // not a git repository}def repository = nulltry {repository = new FileRepositoryBuilder()+ .findGitDir(rootProject.projectDir).setWorkTree(rootProject.projectDir).setMustExist(true).build()