mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-04 03:10:50 +01:00
Implement more complex implicit directories
This commit is contained in:
@@ -95,7 +95,7 @@ class HgFileviewCommandResultReader {
|
||||
|
||||
private boolean isAncestor(FileObject ancestor, FileObject child) {
|
||||
String ancestorPath = ancestor.getPath();
|
||||
return child.getParentPath().startsWith(ancestorPath);
|
||||
return ancestorPath.equals("") || child.getParentPath().startsWith(ancestorPath + '/');
|
||||
}
|
||||
|
||||
private Collection<FileObject> createMissingParents(FileObject current, FileObject file) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Iterator;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
@@ -180,6 +181,41 @@ class HgFileviewCommandResultReaderTest {
|
||||
.containsExactly(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCreateSimilarSubDirectoriesCorrectly() throws IOException {
|
||||
HgFileviewCommandResultReader reader = new MockInput()
|
||||
.dir("")
|
||||
.file("dir/a.txt")
|
||||
.file("directory/b.txt")
|
||||
.build();
|
||||
|
||||
FileObject fileObject = reader.parseResult();
|
||||
|
||||
assertThat(fileObject.getChildren())
|
||||
.extracting("name")
|
||||
.containsExactly("dir", "directory");
|
||||
assertThat(fileObject.getChildren())
|
||||
.extracting("directory")
|
||||
.containsExactly(true, true);
|
||||
|
||||
Iterator<FileObject> fileIterator = fileObject.getChildren().iterator();
|
||||
FileObject firstSubDir = fileIterator.next();
|
||||
assertThat(firstSubDir.getChildren())
|
||||
.extracting("name")
|
||||
.containsExactly("a.txt");
|
||||
assertThat(firstSubDir.getChildren())
|
||||
.extracting("directory")
|
||||
.containsExactly(false);
|
||||
|
||||
FileObject secondSubDir = fileIterator.next();
|
||||
assertThat(secondSubDir.getChildren())
|
||||
.extracting("name")
|
||||
.containsExactly("b.txt");
|
||||
assertThat(secondSubDir.getChildren())
|
||||
.extracting("directory")
|
||||
.containsExactly(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldIgnoreTimeAndCommentWhenDisabled() throws IOException {
|
||||
HgFileviewCommandResultReader reader = new MockInput()
|
||||
|
||||
Reference in New Issue
Block a user