Skip to content

GH-1849 Fix WorkingDirectoryChangesDetector for git submodule work trees - #1850

Open
lindsaythurmond wants to merge 1 commit into
spring-projects:mainfrom
lindsaythurmond:fix-working-directory-detector-git-submodules
Open

GH-1849 Fix WorkingDirectoryChangesDetector for git submodule work trees#1850
lindsaythurmond wants to merge 1 commit into
spring-projects:mainfrom
lindsaythurmond:fix-working-directory-detector-git-submodules

Conversation

@lindsaythurmond

Copy link
Copy Markdown

Closes #1849

Summary

WorkingDirectoryChangesDetector.of() resolves the repository root via repository.getDirectory().getParent(). In a git submodule checkout, .git is a gitdir: pointer into the parent repository's .git/modules/... directory, so that path points at git metadata rather than the submodule work tree.

When JUnit tests run from a nested Maven module inside such a work tree, computing the repository-relative working directory can throw StringIndexOutOfBoundsException during ModulithExecutionCondition evaluation — before any application tests execute.

Fix

Use repository.getWorkTree().getAbsolutePath() as the repository root, which is correct for standard repositories and submodule work trees alike.

Path computation is extracted into repositoryRelativeWorkingDirectory(...) so it can be unit-tested directly (without relying on JVM working-directory changes under Surefire).

Tests

  • Repository-relative path resolution for nested Maven modules
  • Git submodule-style work tree with external git directory
  • Filtering modified files to the current nested module
  • Assertion that git directory parent and work tree differ for submodule layouts

…bmodule work trees.

Use the Git work tree instead of the git directory parent when resolving
the repository-relative working directory. Add tests for submodule layouts
and extract path computation for unit testing.

Signed-off-by: Lindsay Thurmond <lindsay.thurmond@gmail.com>
@lindsaythurmond
lindsaythurmond force-pushed the fix-working-directory-detector-git-submodules branch from 7443916 to d3efc89 Compare September 1, 2026 21:03
@lindsaythurmond lindsaythurmond changed the title GH-1849 Fix WorkingDirectoryChangesDetector for git submodule work trees GH-1849 Fix WorkingDirectoryChangesDetector for git submodule work trees Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WorkingDirectoryChangesDetector fails in git submodule work trees

1 participant