diff --git a/src/components/repo/RepoLog.tsx b/src/components/repo/RepoLog.tsx index 3044d22..97b513c 100644 --- a/src/components/repo/RepoLog.tsx +++ b/src/components/repo/RepoLog.tsx @@ -6,10 +6,11 @@ import { RepoCommit as RepoCommitComponent } from './RepoCommit' import { WorkspacePaneHeader } from './WorkspacePaneHeader' type RepoLogProps = { + branch?: string repo: Repo } -export function RepoLog({ repo }: RepoLogProps) { +export function RepoLog({ branch, repo }: RepoLogProps) { const [commits, setCommits] = useState(null) const [error, setError] = useState(null) @@ -20,7 +21,7 @@ export function RepoLog({ repo }: RepoLogProps) { setError(null) try { - const response = await getRecentCommits(repo) + const response = await getRecentCommits(repo, { branch }) if (!cancelled) setCommits(response) } catch (caught) { if (!cancelled) { @@ -34,7 +35,7 @@ export function RepoLog({ repo }: RepoLogProps) { return () => { cancelled = true } - }, [repo]) + }, [branch, repo]) if (error) { return

Could not load commits: {error.message}

diff --git a/src/components/repo/RepoWorkspace.tsx b/src/components/repo/RepoWorkspace.tsx index 6a70bb3..7afcfe8 100644 --- a/src/components/repo/RepoWorkspace.tsx +++ b/src/components/repo/RepoWorkspace.tsx @@ -15,7 +15,7 @@ export function RepoWorkspace({ initialTree, repo }: RepoWorkspaceProps) {
- +
) diff --git a/src/lib/tangled/repo.ts b/src/lib/tangled/repo.ts index 159b226..fedf2f7 100644 --- a/src/lib/tangled/repo.ts +++ b/src/lib/tangled/repo.ts @@ -155,9 +155,17 @@ export async function getRepoLog( return commits.text() } -export async function getRecentCommits(repo: Repo, limit = 5): Promise { - const branch = await getDefaultBranch(repo) - const raw = await getRepoLog(repo, branch.name, { limit }) +export type RecentCommitsOptions = { + branch?: string + limit?: number +} + +export async function getRecentCommits( + repo: Repo, + options: RecentCommitsOptions = {}, +): Promise { + const branch = options.branch ?? (await getDefaultBranch(repo)).name + const raw = await getRepoLog(repo, branch, { limit: options.limit ?? 5 }) let parsed: unknown try {