| 1 | import Link from "next/link"; |
| 2 | import { notFound } |
| 3 | |
| 4 | import { FromNowHoverCard } |
| 5 | import { CommitVerificationBadge } |
| 6 | import { createServerClient } |
| 7 | |
| 8 | export default async function |
| 9 | params, |
| 10 | }: PageProps< |
| 11 | const { username, |
| 12 | |
| 13 | const client = |
| 14 | const path = |
| 15 | |
| 16 | const [commits, |
| 17 | client.GET("/api/repositories/{username}/{repo}/pulls/{number}/commits |
| 18 | params: { path |
| 19 | }), |
| 20 | client.GET("/api/repositories/{username}/{repo}/pulls/{number} |
| 21 | params: { path |
| 22 | }), |
| 23 | ]); |
| 24 | |
| 25 | if (commits.response |
| 26 | if (!commits.data |
| 27 | throw new Error( |
| 28 | } |
| 29 | |
| 30 | // These commits are reachable in the head repository, which is a different repository - and a different object store - whenever the request is a fork. A merge copied them into the base, which is all that is left once the head repository is deleted. |
| 31 | const { head |
| 32 | const commitBase = |
| 33 | ? `/${head. |
| 34 | : `/${username} |
| 35 | |
| 36 | return ( |
| 37 | <div className="overflow-hidden rounded-lg border |
| 38 | {commits.data.commits |
| 39 | <p className="py-16 text-center text-sm text-muted-foreground |
| 40 | This branch adds no commits to the base. |
| 41 | </p> |
| 42 | ) : ( |
| 43 | <ul className="divide-y |
| 44 | {commits.data.commits |
| 45 | <li |
| 46 | key={commit.sha |
| 47 | className="flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40" |
| 48 | > |
| 49 | <div className="min-w-0 flex-1 |
| 50 | <Link |
| 51 | href={`${commitBase |
| 52 | className="truncate font-medium hover:underline" |
| 53 | > |
| 54 | {commit.subject} |
| 55 | </Link> |
| 56 | <p className="truncate text-xs text-muted-foreground |
| 57 | {commit.authorName} committed |
| 58 | <FromNowHoverCard date={ |
| 59 | </p> |
| 60 | </div> |
| 61 | <CommitVerificationBadge verification={ |
| 62 | <Link |
| 63 | href={`${commitBase |
| 64 | className="shrink-0 font-mono text-xs text-muted-foreground hover:underline" |
| 65 | > |
| 66 | {commit.sha.slice |
| 67 | </Link> |
| 68 | </li> |
| 69 | ))} |
| 70 | </ul> |
| 71 | )} |
| 72 | </div> |
| 73 | ); |
| 74 | } |