Skip to content

armgit / solr

Public Imported from GitHub
0

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.gradle
index 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 status
try {
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.gradle
index 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 = true
rootProject.ext.ratGitTrackedFiles = null
+ // .git is a file (not a directory) in a git worktree
def dotGit = new File(rootProject.projectDir, ".git")
- if (!dotGit.isDirectory()) {
+ if (!dotGit.exists()) {
return null // not a git repository
}
def repository = null
try {
repository = new FileRepositoryBuilder()
+ .findGitDir(rootProject.projectDir)
.setWorkTree(rootProject.projectDir)
.setMustExist(true)
.build()