Add explanatory text in logic part, rename some variables

This commit is contained in:
Florian Scholdei
2020-10-07 20:33:09 +02:00
parent 9271da85a5
commit a2f1c88bfd
2 changed files with 14 additions and 10 deletions

View File

@@ -194,29 +194,29 @@ public class SvnBrowseCommand extends AbstractSvnCommand
repository.getDir(entry.getRelativePath(), revision, properties, (Collection) null);
String externals = properties.getStringValue(SVNProperty.EXTERNALS).replaceAll("[\\r\\n]+", "");
String[] externalsArray = externals.split(" ");
String subRepoName = "";
for (String external : externalsArray) {
String subRepoUrl = "";
String subRepoPath = "";
for (String external : externals.split(" ")) {
if (shouldSetExternal(external)) {
externals = external;
subRepoUrl = external;
} else if (!external.contains("-r") && !external.isEmpty()) {
subRepoName = external;
subRepoPath = external;
}
}
if (Util.isNotEmpty(externals)) {
SubRepository subRepository = new SubRepository(externals);
fileObject.addChild(createSubRepoDirectory(subRepository, subRepoName));
SubRepository subRepository = new SubRepository(subRepoUrl);
fileObject.addChild(createSubRepoDirectory(subRepository, subRepoPath));
}
} catch (SVNException ex) {
logger.error("could not fetch file properties", ex);
}
}
private FileObject createSubRepoDirectory(SubRepository subRepository, String subRepoName) {
private FileObject createSubRepoDirectory(SubRepository subRepository, String subRepoPath) {
FileObject subRepositoryDirectory = new FileObject();
subRepositoryDirectory.setPath(subRepoName);
subRepositoryDirectory.setName(subRepoName);
subRepositoryDirectory.setPath(subRepoPath);
subRepositoryDirectory.setName(subRepoPath);
subRepositoryDirectory.setDirectory(true);
subRepositoryDirectory.setSubRepository(subRepository);
return subRepositoryDirectory;

View File

@@ -69,8 +69,10 @@ export const createFolderLink = (base: string, file: File) => {
const FileLink: FC<Props> = ({ baseUrl, file, children }) => {
const [t] = useTranslation("repos");
if (file?.subRepository?.repositoryUrl) {
// file link represents a subRepository
let link = file.subRepository.repositoryUrl;
if (file.subRepository.browserUrl) {
// replace upstream url with public browser url
link = file.subRepository.browserUrl;
}
if (link.startsWith("http://") || link.startsWith("https://")) {
@@ -85,6 +87,7 @@ const FileLink: FC<Props> = ({ baseUrl, file, children }) => {
}
return <Link to={link}>{children}</Link>;
} else {
// subRepository url cannot be linked
return (
<Tooltip location="top" message={t("sources.fileTree.subRepository") + ": \n" + link}>
{children}
@@ -92,6 +95,7 @@ const FileLink: FC<Props> = ({ baseUrl, file, children }) => {
);
}
}
// normal file or folder
return <Link to={createFolderLink(baseUrl, file)}>{children}</Link>;
};