mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-07 16:12:10 +01:00
Do not fail without default branch
This selects the first branch, if no default branch is present. Committed-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com> Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com> Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
committed by
SCM-Manager
parent
d4e03c6f70
commit
e679dac94d
3
gradle/changelog/hg_default_branch.yaml
Normal file
3
gradle/changelog/hg_default_branch.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
- type: fixed
|
||||
description: Error in frontend without 'default' branch in hg repositories
|
||||
|
||||
@@ -63,8 +63,10 @@ const Sources: FC<Props> = ({ repository, branches, selectedBranch, baseUrl }) =
|
||||
// redirect to default branch if no branch selected
|
||||
useEffect(() => {
|
||||
if (branches && branches.length > 0 && !selectedBranch) {
|
||||
const defaultBranch = branches?.filter(b => b.defaultBranch === true)[0];
|
||||
history.replace(`${baseUrl}/sources/${encodeURIComponent(defaultBranch.name)}/`);
|
||||
const defaultBranch = branches?.filter((b) => b.defaultBranch === true)[0];
|
||||
history.replace(
|
||||
`${baseUrl}/sources/${defaultBranch ? encodeURIComponent(defaultBranch.name) : encodeURIComponent(branches[0].name)}/`
|
||||
);
|
||||
}
|
||||
}, [branches, selectedBranch, history, baseUrl]);
|
||||
const { isLoading, error, data: file, isFetchingNextPage, fetchNextPage } = useSources(repository, {
|
||||
|
||||
Reference in New Issue
Block a user