diff --git a/src/views/projects/BranchSelector.svelte b/src/views/projects/BranchSelector.svelte index 2f35b96a5..64a23248a 100644 --- a/src/views/projects/BranchSelector.svelte +++ b/src/views/projects/BranchSelector.svelte @@ -1,30 +1,20 @@ ; + export let branches: Record | undefined; export let commit: Commit; export let commitCount: number; export let contributorCount: number; @@ -61,6 +61,7 @@ ; + export let branches: Record | undefined; export let commitCount: number; export let commitHeaders: CommitHeader[]; export let contributorCount: number; @@ -85,6 +85,7 @@ ; + export let branches: Record | undefined; + export let commitCount: number; + export let contributorCount: number; export let defaultBranch: string; export let peer: string | undefined; export let peers: Remote[]; export let projectId: string; export let resource: LoadedSourceBrowsingView["resource"]; export let revision: string | undefined; + export let commitId: string; - export let commitCount: number; - export let contributorCount: number; + let selectedBranch: string | undefined; + + // Revision may be a commit ID, a branch name or `undefined` which means the + // default branch. We assign `selectedBranch` accordingly. + // TODO: Move this logic out of here and have `selectedBranch` be passed as a + // prop. + $: if (revision === commitId) { + selectedBranch = undefined; + } else { + selectedBranch = revision ?? defaultBranch; + }