mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Remove pseudo error handling
This commit is contained in:
@@ -168,67 +168,52 @@ public class GitBrowseCommand extends AbstractGitCommand
|
|||||||
private FileObject createFileObject(org.eclipse.jgit.lib.Repository repo,
|
private FileObject createFileObject(org.eclipse.jgit.lib.Repository repo,
|
||||||
BrowseCommandRequest request, ObjectId revId, TreeWalk treeWalk)
|
BrowseCommandRequest request, ObjectId revId, TreeWalk treeWalk)
|
||||||
throws IOException, RevisionNotFoundException {
|
throws IOException, RevisionNotFoundException {
|
||||||
FileObject file;
|
|
||||||
|
|
||||||
try
|
FileObject file = new FileObject();
|
||||||
|
|
||||||
|
String path = treeWalk.getPathString();
|
||||||
|
|
||||||
|
file.setName(treeWalk.getNameString());
|
||||||
|
file.setPath(path);
|
||||||
|
|
||||||
|
SubRepository sub = null;
|
||||||
|
|
||||||
|
if (!request.isDisableSubRepositoryDetection())
|
||||||
{
|
{
|
||||||
file = new FileObject();
|
sub = getSubRepository(repo, revId, path);
|
||||||
|
}
|
||||||
|
|
||||||
String path = treeWalk.getPathString();
|
if (sub != null)
|
||||||
|
{
|
||||||
|
logger.trace("{} seems to be a sub repository", path);
|
||||||
|
file.setDirectory(true);
|
||||||
|
file.setSubRepository(sub);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ObjectLoader loader = repo.open(treeWalk.getObjectId(0));
|
||||||
|
|
||||||
file.setName(treeWalk.getNameString());
|
file.setDirectory(loader.getType() == Constants.OBJ_TREE);
|
||||||
file.setPath(path);
|
file.setLength(loader.getSize());
|
||||||
|
|
||||||
SubRepository sub = null;
|
// don't show message and date for directories to improve performance
|
||||||
|
if (!file.isDirectory() &&!request.isDisableLastCommit())
|
||||||
if (!request.isDisableSubRepositoryDetection())
|
|
||||||
{
|
{
|
||||||
sub = getSubRepository(repo, revId, path);
|
logger.trace("fetch last commit for {} at {}", path, revId.getName());
|
||||||
}
|
RevCommit commit = getLatestCommit(repo, revId, path);
|
||||||
|
|
||||||
if (sub != null)
|
if (commit != null)
|
||||||
{
|
|
||||||
logger.trace("{} seems to be a sub repository", path);
|
|
||||||
file.setDirectory(true);
|
|
||||||
file.setSubRepository(sub);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ObjectLoader loader = repo.open(treeWalk.getObjectId(0));
|
|
||||||
|
|
||||||
file.setDirectory(loader.getType() == Constants.OBJ_TREE);
|
|
||||||
file.setLength(loader.getSize());
|
|
||||||
|
|
||||||
// don't show message and date for directories to improve performance
|
|
||||||
if (!file.isDirectory() &&!request.isDisableLastCommit())
|
|
||||||
{
|
{
|
||||||
logger.trace("fetch last commit for {} at {}", path, revId.getName());
|
file.setLastModified(GitUtil.getCommitTime(commit));
|
||||||
RevCommit commit = getLatestCommit(repo, revId, path);
|
file.setDescription(commit.getShortMessage());
|
||||||
|
}
|
||||||
if (commit != null)
|
else if (logger.isWarnEnabled())
|
||||||
{
|
{
|
||||||
file.setLastModified(GitUtil.getCommitTime(commit));
|
logger.warn("could not find latest commit for {} on {}", path,
|
||||||
file.setDescription(commit.getShortMessage());
|
revId);
|
||||||
}
|
|
||||||
else if (logger.isWarnEnabled())
|
|
||||||
{
|
|
||||||
logger.warn("could not find latest commit for {} on {}", path,
|
|
||||||
revId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MissingObjectException ex)
|
|
||||||
{
|
|
||||||
file = null;
|
|
||||||
logger.error("could not fetch object for id {}", revId);
|
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
|
||||||
{
|
|
||||||
logger.trace("could not fetch object", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,21 +316,17 @@ public class GitBrowseCommand extends AbstractGitCommand
|
|||||||
while (treeWalk.next())
|
while (treeWalk.next())
|
||||||
{
|
{
|
||||||
|
|
||||||
FileObject fo = createFileObject(repo, request, revId, treeWalk);
|
FileObject fileObject = createFileObject(repo, request, revId, treeWalk);
|
||||||
if (!fo.getPath().startsWith(parent.getPath())) {
|
if (!fileObject.getPath().startsWith(parent.getPath())) {
|
||||||
parent.setChildren(files);
|
parent.setChildren(files);
|
||||||
return fo;
|
return fileObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files.add(fileObject);
|
||||||
|
|
||||||
if (fo != null)
|
if (request.isRecursive() && fileObject.isDirectory()) {
|
||||||
{
|
|
||||||
files.add(fo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.isRecursive() && fo.isDirectory()) {
|
|
||||||
treeWalk.enterSubtree();
|
treeWalk.enterSubtree();
|
||||||
FileObject rc = findChildren(fo, repo, request, revId, treeWalk);
|
FileObject rc = findChildren(fileObject, repo, request, revId, treeWalk);
|
||||||
if (rc != null) {
|
if (rc != null) {
|
||||||
files.add(rc);
|
files.add(rc);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user