import config from "../../config.ts"; import type { RepositoryRow } from "../../db/index.ts"; import type { SessionUser } from "../../middleware/session.ts"; import type { TreeEntry } from "../../services/git.ts"; import { Layout } from "../layout.tsx"; import { BranchSelector } from "./BranchSelector.tsx"; import { FileTreeTable } from "./FileTreeTable.tsx"; import { RepoHeader } from "./RepoHeader.tsx"; import { RepoNav } from "./RepoNav.tsx"; interface RepoHomeProps { user: SessionUser | null; repo: RepositoryRow; entries: TreeEntry[]; readmeHtml: string | null; readmePath?: string; hasContent: boolean; branches: string[]; tags?: string[]; } export function RepoHome({ user, repo, entries, readmeHtml, readmePath, hasContent, branches, tags, }: RepoHomeProps) { return (
{!!repo.description && (

{repo.description}

)} {!hasContent ? (

This repository is empty.

Push your first commit to get started:

                            {`git clone ${httpUrl(repo.name)}${
                                config.SSH_DISABLED
                                    ? ""
                                    : `\n# or: git clone ${sshUrl(repo.name)}`
                            }
cd ${repo.name}
echo "# ${repo.name}" > README.md
git add .
git commit -m "Initial commit"
git push origin main`}
                        
) : ( <>
{branches.includes(repo.default_branch) && user?.isAdmin && ( New file )}
Clone
HTTP
{!config.SSH_DISABLED && (
SSH
)}
{!!readmeHtml && (
README {!!readmePath && ( Raw )}
{readmeHtml as "safe"}
)} )}
); } function httpUrl(name: string) { return `${config.BASE_URL}/${name}.git`; } function sshUrl(name: string) { const host = new URL(config.BASE_URL).hostname; return `ssh://git@${host}:${config.SSH_PORT}/${name}.git`; }