Skip to content

Commit c7f43cb

Browse files
committed
Fix affected projects for multiple changed files
1 parent d9ef704 commit c7f43cb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

gradle/ci_jobs.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ if (rootProject.hasProperty("gitBaseRef")) {
123123

124124
// Get all projects, sorted by descending path length.
125125
final projects = subprojects.sort { a, b -> b.projectDir.path.length() <=> a.projectDir.path.length() }
126+
Map<Project, Set<String>> _affectedProjects = [:]
126127
for (File f in rootProject.changedFiles) {
127128
Project p = projects.find { f.toString().startsWith(it.projectDir.path + "/") }
128129
if (p == null) {
@@ -132,7 +133,6 @@ if (rootProject.hasProperty("gitBaseRef")) {
132133
}
133134
final relPath = Paths.get(p.projectDir.path).relativize(f.toPath())
134135
final pathComponents = relPath.collect({ it.toString() }).toList()
135-
Map<Project, Set<String>> _affectedProjects = [:]
136136
if (pathComponents.size() < 3) {
137137
logger.warn("Changed file: ${relativeToGitRoot(f)} in project ${p.path} (all)")
138138
_affectedProjects.computeIfAbsent(p, { new HashSet<String>() }).add("all")
@@ -149,9 +149,9 @@ if (rootProject.hasProperty("gitBaseRef")) {
149149
logger.warn("Changed file: ${relativeToGitRoot(f)} in project ${p.path} (all)")
150150
_affectedProjects.computeIfAbsent(p, { new HashSet<String>() }).add("all")
151151
}
152-
rootProject.ext {
153-
it.affectedProjects = _affectedProjects
154-
}
152+
}
153+
rootProject.ext {
154+
it.affectedProjects = _affectedProjects
155155
}
156156
}
157157

0 commit comments

Comments
 (0)