mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-05 20:00:55 +01:00
Add 'partial' flag to files
This commit is contained in:
@@ -222,6 +222,10 @@ public class FileObject implements LastModifiedAware, Serializable
|
||||
return directory;
|
||||
}
|
||||
|
||||
public boolean isPartialResult() {
|
||||
return partialResult;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -302,6 +306,10 @@ public class FileObject implements LastModifiedAware, Serializable
|
||||
this.subRepository = subRepository;
|
||||
}
|
||||
|
||||
public void setPartialResult(boolean partialResult) {
|
||||
this.partialResult = partialResult;
|
||||
}
|
||||
|
||||
public Collection<FileObject> getChildren() {
|
||||
return unmodifiableCollection(children);
|
||||
}
|
||||
@@ -338,6 +346,8 @@ public class FileObject implements LastModifiedAware, Serializable
|
||||
/** file path */
|
||||
private String path;
|
||||
|
||||
private boolean partialResult = false;
|
||||
|
||||
/** sub repository informations */
|
||||
@XmlElement(name = "subrepository")
|
||||
private SubRepository subRepository;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user