| 1 | using AgentForge.Services; |
| 2 | |
| 3 | namespace AgentForge.Plugin.View.Components.Code; |
| 4 | |
| 5 | internal static class ForgeViewCodeRootListing |
| 6 | { |
| 7 | internal static string Render(string repoName, GitRepoService git) |
| 8 | { |
| 9 | if (!git.BareRepoExists(repoName)) |
| 10 | return ForgeHtml.P("meta", ForgeHtml.Text("No commits yet — clone and push to populate.")); |
| 11 | |
| 12 | var branch = ForgeGitViewHelpers.ResolveBranch(git, repoName, branch: null); |
| 13 | var tip = git.GetBranchTipCommit(repoName, branch); |
| 14 | var treeHref = $"/view/repos/{ForgeRepoNames.ToUrlPath(repoName)}/tree?branch={Uri.EscapeDataString(branch)}"; |
| 15 | |
| 16 | var meta = ForgeHtml.P("meta", |
| 17 | ForgeHtml.Text("branch "), |
| 18 | ForgeHtml.Badge(branch), |
| 19 | tip is { Length: > 0 } |
| 20 | ? ForgeHtml.Fragment(ForgeHtml.Text(" · "), ForgeHtml.Text(tip[..Math.Min(8, tip.Length)])) |
| 21 | : "", |
| 22 | ForgeHtml.Text(" · "), |
| 23 | ForgeHtml.A(treeHref, "browse all files")); |
| 24 | |
| 25 | var tree = ForgeViewFileTree.RenderEntriesOnly( |
| 26 | repoName, |
| 27 | branch, |
| 28 | git.ListDirectory(repoName, branch, path: null)); |
| 29 | |
| 30 | return ForgeHtml.Fragment(meta, tree); |
| 31 | } |
| 32 | } |
| 33 | |