Fix hg fileview resolves for same path on file and directory (#1746)

If a file and a directory with the same name existed somewhere at the same level in a Mercurial repository, our logic in the fileview command failed to collect them. The parent of the file was mistaken for the entire file path, resulting in confusing errors that the file could not be found in the manifest. With this fix, file detection should now be more secure than before.

Co-authored-by: Sebastian Sdorra <sebastian.sdorra@cloudogu.com>
This commit is contained in:
Eduard Heimbuch
2021-07-28 11:22:37 +02:00
committed by GitHub
parent 91fec0f478
commit e68c178c86
4 changed files with 23 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ import { useTranslation } from "react-i18next";
import { useHistory, useLocation, useParams } from "react-router-dom";
import { useSources } from "@scm-manager/ui-api";
import { Branch, Repository } from "@scm-manager/ui-types";
import { Breadcrumb, Loading, Notification } from "@scm-manager/ui-components";
import { Breadcrumb, ErrorNotification, Loading, Notification } from "@scm-manager/ui-components";
import FileTree from "../components/FileTree";
import Content from "./Content";
import CodeActionBar from "../../codeSection/components/CodeActionBar";
@@ -80,6 +80,10 @@ const Sources: FC<Props> = ({ repository, branches, selectedBranch, baseUrl }) =
enabled: !branches || !!selectedBranch,
});
if (error) {
return <ErrorNotification error={error} />;
}
if (isLoading || (!error && !file)) {
return <Loading />;
}