From ee9d8893a73b8607b43d86c569674a73a65b5a70 Mon Sep 17 00:00:00 2001 From: bytedream Date: Thu, 8 Jan 2026 21:04:51 +0100 Subject: [PATCH] Fix file-tree ui error when adding files to repo without commits (#36312) When visiting the new file & upload file pages on a repo that has no commits, the request for file-tree files fails. --- Screenshot_20260106_175938 image --------- Signed-off-by: wxiaoguang Co-authored-by: wxiaoguang --- web_src/js/components/ViewFileTreeStore.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web_src/js/components/ViewFileTreeStore.ts b/web_src/js/components/ViewFileTreeStore.ts index 936db07776..4237f7e323 100644 --- a/web_src/js/components/ViewFileTreeStore.ts +++ b/web_src/js/components/ViewFileTreeStore.ts @@ -20,6 +20,9 @@ export function createViewFileTreeStore(props: {repoLink: string, treePath: stri selectedItem: props.treePath, async loadChildren(treePath: string, subPath: string = '') { + // there is no git ref if no commits were made yet (an empty repo) + if (!props.currentRefNameSubURL) return null; + const response = await GET(`${props.repoLink}/tree-view/${props.currentRefNameSubURL}/${pathEscapeSegments(treePath)}?sub_path=${encodeURIComponent(subPath)}`); const json = await response.json(); const poolSvgs = [];