mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-05 03:40:56 +01:00
Fix review finding
This commit is contained in:
@@ -54,12 +54,10 @@ import static sonia.scm.NotFoundException.notFound;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
implements BrowseCommand
|
||||
{
|
||||
implements BrowseCommand {
|
||||
|
||||
/**
|
||||
* the logger for SvnBrowseCommand
|
||||
@@ -69,8 +67,7 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
|
||||
private int resultCount = 0;
|
||||
|
||||
SvnBrowseCommand(SvnContext context)
|
||||
{
|
||||
SvnBrowseCommand(SvnContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -86,8 +83,7 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
|
||||
BrowserResult result = null;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
SVNRepository svnRepository = open();
|
||||
|
||||
if (revisionNumber == -1) {
|
||||
@@ -104,9 +100,7 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
|
||||
|
||||
result = new BrowserResult(String.valueOf(revisionNumber), root);
|
||||
}
|
||||
catch (SVNException ex)
|
||||
{
|
||||
} catch (SVNException ex) {
|
||||
if (FS_NO_SUCH_REVISION.equals(ex.getErrorMessage().getErrorCode())) {
|
||||
throw notFound(entity("Revision", Long.toString(revisionNumber)).in(this.repository));
|
||||
}
|
||||
@@ -120,9 +114,8 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void traverse(SVNRepository svnRepository, long revisionNumber, BrowseCommandRequest request,
|
||||
FileObject parent, String basePath)
|
||||
throws SVNException
|
||||
{
|
||||
FileObject parent, String basePath)
|
||||
throws SVNException {
|
||||
List<SVNDirEntry> entries = new ArrayList<>(svnRepository.getDir(parent.getPath(), revisionNumber, null, (Collection) null));
|
||||
sort(entries, entry -> entry.getKind() == SVNNodeKind.DIR, SVNDirEntry::getName);
|
||||
for (Iterator<SVNDirEntry> iterator = entries.iterator(); resultCount < request.getLimit() + request.getOffset() && iterator.hasNext(); ) {
|
||||
@@ -146,16 +139,13 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
}
|
||||
}
|
||||
|
||||
private String createBasePath(String path)
|
||||
{
|
||||
private String createBasePath(String path) {
|
||||
String basePath = Util.EMPTY_STRING;
|
||||
|
||||
if (Util.isNotEmpty(path))
|
||||
{
|
||||
if (Util.isNotEmpty(path)) {
|
||||
basePath = path;
|
||||
|
||||
if (!basePath.endsWith("/"))
|
||||
{
|
||||
if (!basePath.endsWith("/")) {
|
||||
basePath = basePath.concat("/");
|
||||
}
|
||||
}
|
||||
@@ -164,8 +154,7 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
}
|
||||
|
||||
private FileObject createFileObject(BrowseCommandRequest request,
|
||||
SVNRepository repository, long revision, SVNDirEntry entry, String path)
|
||||
{
|
||||
SVNRepository repository, long revision, SVNDirEntry entry, String path) {
|
||||
if (entry == null) {
|
||||
throw notFound(entity("Path", path).in("Revision", Long.toString(revision)).in(this.repository));
|
||||
}
|
||||
@@ -175,10 +164,8 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
fileObject.setPath(path.concat(entry.getRelativePath()));
|
||||
fileObject.setDirectory(entry.getKind() == SVNNodeKind.DIR);
|
||||
|
||||
if (!request.isDisableLastCommit())
|
||||
{
|
||||
if (entry.getDate() != null)
|
||||
{
|
||||
if (!request.isDisableLastCommit()) {
|
||||
if (entry.getDate() != null) {
|
||||
fileObject.setCommitDate(entry.getDate().getTime());
|
||||
}
|
||||
|
||||
@@ -188,43 +175,41 @@ public class SvnBrowseCommand extends AbstractSvnCommand
|
||||
fileObject.setLength(entry.getSize());
|
||||
|
||||
if (!request.isDisableSubRepositoryDetection() && fileObject.isDirectory()
|
||||
&& entry.hasProperties())
|
||||
{
|
||||
&& entry.hasProperties()) {
|
||||
fetchExternalsProperty(repository, revision, entry, fileObject);
|
||||
}
|
||||
|
||||
return fileObject;
|
||||
}
|
||||
|
||||
private boolean shouldSetExternal(String external) {
|
||||
return (external.startsWith("http://") || external.startsWith("https://") || external.startsWith("../")
|
||||
|| external.startsWith("^/") || external.startsWith("/"));
|
||||
}
|
||||
|
||||
private void fetchExternalsProperty(SVNRepository repository, long revision,
|
||||
SVNDirEntry entry, FileObject fileObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
SVNDirEntry entry, FileObject fileObject) {
|
||||
try {
|
||||
SVNProperties properties = new SVNProperties();
|
||||
|
||||
repository.getDir(entry.getRelativePath(), revision, properties, (Collection) null);
|
||||
|
||||
String externals = properties.getStringValue(SVNProperty.EXTERNALS).replaceAll("[\\r\\n]+", "");
|
||||
String[] externalsArray = externals.split(" ");
|
||||
for(String external: externalsArray)
|
||||
{
|
||||
if(external.startsWith("http://") || external.startsWith("https://") || external.startsWith("../")
|
||||
|| external.startsWith("^/") || external.startsWith("/"))
|
||||
{
|
||||
for (String external : externalsArray) {
|
||||
if (shouldSetExternal(external)) {
|
||||
externals = external;
|
||||
}
|
||||
}
|
||||
|
||||
if (Util.isNotEmpty(externals))
|
||||
{
|
||||
if (Util.isNotEmpty(externals)) {
|
||||
SubRepository subRepository = new SubRepository(externals);
|
||||
|
||||
fileObject.setSubRepository(subRepository);
|
||||
FileObject subRepositoryDirectory = new FileObject();
|
||||
subRepositoryDirectory.setSubRepository(subRepository);
|
||||
fileObject.addChild(subRepositoryDirectory);
|
||||
}
|
||||
}
|
||||
catch (SVNException ex)
|
||||
{
|
||||
} catch (SVNException ex) {
|
||||
logger.error("could not fetch file properties", ex);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user