Add 'partial' flag to files

This commit is contained in:
Rene Pfeuffer
2019-12-11 14:41:42 +01:00
parent 9caf6c0984
commit 8129f2fad0
3 changed files with 17 additions and 0 deletions

View File

@@ -210,6 +210,7 @@ public class GitBrowseCommand extends AbstractGitCommand
// don't show message and date for directories to improve performance
if (!file.isDirectory() &&!request.isDisableLastCommit())
{
file.setPartialResult(true);
executor.execute(executionType -> {
logger.trace("fetch last commit for {} at {}", path, revId.getName());
RevCommit commit = getLatestCommit(repo, revId, path);
@@ -235,6 +236,7 @@ public class GitBrowseCommand extends AbstractGitCommand
file.setLength(loader.getSize());
}
file.setPartialResult(false);
if (commit != null) {
file.setLastModified(GitUtil.getCommitTime(commit));
file.setDescription(commit.getShortMessage());

View File

@@ -131,22 +131,27 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase {
FileObject a = findFile(foList, "a.txt");
FileObject b = findFile(foList, "b.txt");
assertTrue(a.isPartialResult());
assertNull("expected empty name before commit could have been read", a.getDescription());
assertNull("expected empty date before commit could have been read", a.getLastModified());
assertTrue(b.isPartialResult());
assertNull("expected empty name before commit could have been read", b.getDescription());
assertNull("expected empty date before commit could have been read", b.getLastModified());
executor.next();
assertEquals(1, updatedResults.size());
assertFalse(a.isPartialResult());
assertNotNull("expected correct name after commit could have been read", a.getDescription());
assertNotNull("expected correct date after commit could have been read", a.getLastModified());
assertTrue(b.isPartialResult());
assertNull("expected empty name before commit could have been read", b.getDescription());
assertNull("expected empty date before commit could have been read", b.getLastModified());
executor.next();
assertEquals(2, updatedResults.size());
assertFalse(b.isPartialResult());
assertNotNull("expected correct name after commit could have been read", b.getDescription());
assertNotNull("expected correct date after commit could have been read", b.getLastModified());
}