diff --git a/gradle/changelog/hg_fileview_command.yaml b/gradle/changelog/hg_fileview_command.yaml new file mode 100644 index 0000000000..3d69ff6dd2 --- /dev/null +++ b/gradle/changelog/hg_fileview_command.yaml @@ -0,0 +1,2 @@ +- type: Fixed + description: Fix file detection on hg fileview command ([#1746](https://github.com/scm-manager/scm-manager/pull/1746)) diff --git a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/fileview.py b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/fileview.py index 0ee335561e..8eca8bdb68 100644 --- a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/fileview.py +++ b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/fileview.py @@ -58,7 +58,7 @@ class File_Collector: def collect(self, paths, path = "", dir_only = False): for p in paths: - if p.startswith(path): + if p.startswith(path + b"/") or path == b"": self.attach(self.extract_name_without_parent(path, p), self.structure, dir_only) def attach(self, branch, trunk, dir_only = False): diff --git a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/fileview_test.py b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/fileview_test.py index 946e6130bb..c32023acc6 100644 --- a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/fileview_test.py +++ b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/fileview_test.py @@ -186,6 +186,21 @@ class Test_File_Viewer(unittest.TestCase): d = collector[0][1] self.assertDirectory(d, "d") + # https://github.com/scm-manager/scm-manager/issues/1719 + def test_with_folder_and_file_same_name(self): + files = ["folder/ThisIsIt/ThisIsIt.sln", "folder/ThisIsIt/ThisIsIt/ThisIsIt.csproj"] + root = self.collect(files) + self.assertChildren(root, ["folder"]) + + root = self.collect(files, "folder") + self.assertChildren(root, ["folder/ThisIsIt"]) + + root = self.collect(files, "folder/ThisIsIt") + self.assertChildren(root, ["folder/ThisIsIt/ThisIsIt", "folder/ThisIsIt/ThisIsIt.sln"]) + + root = self.collect(files, "folder/ThisIsIt/ThisIsIt") + self.assertChildren(root, ["folder/ThisIsIt/ThisIsIt/ThisIsIt.csproj"]) + def collect(self, paths, path = "", recursive = False): revCtx = DummyRevContext(paths) diff --git a/scm-ui/ui-webapp/src/repos/sources/containers/Sources.tsx b/scm-ui/ui-webapp/src/repos/sources/containers/Sources.tsx index 4a8fdfc0f3..da8c42ef98 100644 --- a/scm-ui/ui-webapp/src/repos/sources/containers/Sources.tsx +++ b/scm-ui/ui-webapp/src/repos/sources/containers/Sources.tsx @@ -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 = ({ repository, branches, selectedBranch, baseUrl }) = enabled: !branches || !!selectedBranch, }); + if (error) { + return ; + } + if (isLoading || (!error && !file)) { return ; }