diff --git a/webui2/src/components/code/ref-selector.stories.tsx b/webui2/src/components/code/ref-selector.stories.tsx index b160705c2cec0b7cb01562f03c0964eb534b935a..1bc37daf722828aa1caeace4af12335e86a9c5fa 100644 --- a/webui2/src/components/code/ref-selector.stories.tsx +++ b/webui2/src/components/code/ref-selector.stories.tsx @@ -14,13 +14,13 @@ export default meta; type Story = StoryObj; const sampleRefs = [ - { name: "refs/heads/main", shortName: "main", type: GitRefType.Branch, hash: "abc1", isDefault: true }, - { name: "refs/heads/develop", shortName: "develop", type: GitRefType.Branch, hash: "abc2", isDefault: false }, - { name: "refs/heads/feature/auth", shortName: "feature/auth", type: GitRefType.Branch, hash: "abc3", isDefault: false }, - { name: "refs/heads/fix/login", shortName: "fix/login", type: GitRefType.Branch, hash: "abc4", isDefault: false }, - { name: "refs/tags/v1.0.0", shortName: "v1.0.0", type: GitRefType.Tag, hash: "abc5", isDefault: false }, - { name: "refs/tags/v1.1.0", shortName: "v1.1.0", type: GitRefType.Tag, hash: "abc6", isDefault: false }, - { name: "refs/tags/v2.0.0-rc1", shortName: "v2.0.0-rc1", type: GitRefType.Tag, hash: "abc7", isDefault: false }, + { name: "refs/heads/main", shortName: "main", type: GitRefType.Branch, hash: "abc1" }, + { name: "refs/heads/develop", shortName: "develop", type: GitRefType.Branch, hash: "abc2" }, + { name: "refs/heads/feature/auth", shortName: "feature/auth", type: GitRefType.Branch, hash: "abc3" }, + { name: "refs/heads/fix/login", shortName: "fix/login", type: GitRefType.Branch, hash: "abc4" }, + { name: "refs/tags/v1.0.0", shortName: "v1.0.0", type: GitRefType.Tag, hash: "abc5" }, + { name: "refs/tags/v1.1.0", shortName: "v1.1.0", type: GitRefType.Tag, hash: "abc6" }, + { name: "refs/tags/v2.0.0-rc1", shortName: "v2.0.0-rc1", type: GitRefType.Tag, hash: "abc7" }, ]; export const Default: Story = { diff --git a/webui2/src/routes/$repo.tsx b/webui2/src/routes/$repo.tsx index 24a609bdb111155ae0ada8305764cd9526a07a05..a687a9a5bfe5e736c8fb1369709ff03e11a894dd 100644 --- a/webui2/src/routes/$repo.tsx +++ b/webui2/src/routes/$repo.tsx @@ -7,13 +7,15 @@ export const REFS_QUERY = gql` query CodePageRefs($repo: String) { repository(ref: $repo) { name + head { + hash + } refs { nodes { name shortName type hash - isDefault } } } @@ -23,6 +25,7 @@ export const REFS_QUERY = gql` export interface RefsQueryData { repository: { name: string; + head: { hash: string } | null; refs: { nodes: GitRef[] } | null; } | null; } diff --git a/webui2/src/routes/$repo/index.tsx b/webui2/src/routes/$repo/index.tsx index 0560434ba398f3e841bb743c9f73da4de83cff4b..48c5d839a9d2624fc21c5c95f2ce10a113997973 100644 --- a/webui2/src/routes/$repo/index.tsx +++ b/webui2/src/routes/$repo/index.tsx @@ -14,8 +14,9 @@ export const Route = createFileRoute("/$repo/")({ variables: { repo: ref }, }); const refs = data?.repository?.refs?.nodes ?? []; - const defaultRef = refs.find((r) => r.isDefault) ?? refs[0]; - const refName = defaultRef?.shortName ?? "master"; + const headHash = data?.repository?.head?.hash; + const defaultRef = headHash ? refs.find((r) => r.hash === headHash) : undefined; + const refName = defaultRef?.shortName ?? refs[0]?.shortName ?? "master"; throw redirect({ to: "/$repo/tree/$ref/$",