GH-861 - Polishing.

This commit is contained in:
Oliver Drotbohm
2024-10-08 22:00:18 +02:00
parent 4be1862075
commit 5f1d3903b0
2 changed files with 5 additions and 8 deletions

View File

@@ -100,7 +100,7 @@ public interface FileModificationDetector {
return new ReferenceCommitDetector(referenceCommit);
}
log.info("Using default file modification detector (uncommitted and unpushed changes).");
log.info("Using default file modification detector (uncommitted and unpushed changes):");
return () -> Stream.of(UncommittedChangesDetector.INSTANCE, UnpushedCommitsDetector.INSTANCE)
.flatMap(it -> it.getModifiedFiles());

View File

@@ -57,13 +57,10 @@ class WorkingDirectoryChangesDetector implements FileModificationDetector {
public static WorkingDirectoryChangesDetector of(FileModificationDetector delegate) {
var pathToRepo = JGitUtil.withRepository(it -> it.getDirectory().getParent());
// someFolder/.
var currentWorkingDirectory = new File(".").getAbsolutePath();
// Strip repository base and /.
var repositoryRelative = currentWorkingDirectory.substring(pathToRepo.length() + 1,
currentWorkingDirectory.length() - 2);
var currentWorkingDirectory = new File("").getAbsolutePath();
var repositoryRelative = !pathToRepo.equals(currentWorkingDirectory)
? currentWorkingDirectory.substring(pathToRepo.length() + 1)
: "";
return new WorkingDirectoryChangesDetector(delegate, repositoryRelative);
}