Skip to content

Commit 5f1d390

Browse files
committed
GH-861 - Polishing.
1 parent 4be1862 commit 5f1d390

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

spring-modulith-junit/src/main/java/org/springframework/modulith/junit/diff/FileModificationDetector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static FileModificationDetector getDefaultDetector(@Nullable String refe
100100
return new ReferenceCommitDetector(referenceCommit);
101101
}
102102

103-
log.info("Using default file modification detector (uncommitted and unpushed changes).");
103+
log.info("Using default file modification detector (uncommitted and unpushed changes):");
104104

105105
return () -> Stream.of(UncommittedChangesDetector.INSTANCE, UnpushedCommitsDetector.INSTANCE)
106106
.flatMap(it -> it.getModifiedFiles());

spring-modulith-junit/src/main/java/org/springframework/modulith/junit/diff/WorkingDirectoryChangesDetector.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,10 @@ class WorkingDirectoryChangesDetector implements FileModificationDetector {
5757
public static WorkingDirectoryChangesDetector of(FileModificationDetector delegate) {
5858

5959
var pathToRepo = JGitUtil.withRepository(it -> it.getDirectory().getParent());
60-
61-
// someFolder/.
62-
var currentWorkingDirectory = new File(".").getAbsolutePath();
63-
64-
// Strip repository base and /.
65-
var repositoryRelative = currentWorkingDirectory.substring(pathToRepo.length() + 1,
66-
currentWorkingDirectory.length() - 2);
60+
var currentWorkingDirectory = new File("").getAbsolutePath();
61+
var repositoryRelative = !pathToRepo.equals(currentWorkingDirectory)
62+
? currentWorkingDirectory.substring(pathToRepo.length() + 1)
63+
: "";
6764

6865
return new WorkingDirectoryChangesDetector(delegate, repositoryRelative);
6966
}

0 commit comments

Comments
 (0)