| 1 |
@page "/git/{Repository}" |
| 2 |
@inherits GitPage |
| 3 |
|
| 4 |
<PageTitle>@Repository — git</PageTitle> |
| 5 |
|
| 6 |
<GitBar Repository="@Repository" Reference="@(Reference ?? Info?.Head)" Tab="log"/> |
| 7 |
|
| 8 |
<main class="git-main"> |
| 9 |
@if (Info is not { } info) |
| 10 |
{ |
| 11 |
<section class="block"> |
| 12 |
<p class="empty">No repository called @Repository.</p> |
| 13 |
</section> |
| 14 |
} |
| 15 |
else |
| 16 |
{ |
| 17 |
<section class="block"> |
| 18 |
<h2 class="block-head"> |
| 19 |
<span>@info.DisplayName</span> |
| 20 |
@if (info.Head is { } head) |
| 21 |
{ |
| 22 |
<span class="block-note">on @head</span> |
| 23 |
} |
| 24 |
</h2> |
| 25 |
|
| 26 |
<div class="block-body"> |
| 27 |
<dl class="pairs"> |
| 28 |
@if (info.Description is { } description) |
| 29 |
{ |
| 30 |
<dt>about</dt> |
| 31 |
<dd>@description</dd> |
| 32 |
} |
| 33 |
@if (info.Owner is { } owner) |
| 34 |
{ |
| 35 |
<dt>owner</dt> |
| 36 |
<dd>@owner</dd> |
| 37 |
} |
| 38 |
@if (Service.CloneUrl(info.Name) is { } clone) |
| 39 |
{ |
| 40 |
<dt>clone</dt> |
| 41 |
<dd class="copyable">@clone</dd> |
| 42 |
} |
| 43 |
@if (Refs is { } refs) |
| 44 |
{ |
| 45 |
<dt>refs</dt> |
| 46 |
<dd> |
| 47 |
<a href="@RefsLink()">@Branches(refs), @Tags(refs)</a> |
| 48 |
</dd> |
| 49 |
} |
| 50 |
</dl> |
| 51 |
</div> |
| 52 |
</section> |
| 53 |
|
| 54 |
@if (info.Tip is null) |
| 55 |
{ |
| 56 |
<section class="block"> |
| 57 |
<p class="empty">Nothing committed yet.</p> |
| 58 |
</section> |
| 59 |
} |
| 60 |
else |
| 61 |
{ |
| 62 |
<section class="block"> |
| 63 |
<h2 class="block-head"> |
| 64 |
<span>recent commits</span> |
| 65 |
<span class="block-note"><a href="@LogLink(info.Head)">full log</a></span> |
| 66 |
</h2> |
| 67 |
|
| 68 |
<div class="scroll"> |
| 69 |
<table> |
| 70 |
<tbody> |
| 71 |
@foreach (var commit in Recent) |
| 72 |
{ |
| 73 |
<tr> |
| 74 |
<td class="dim" title="@Exact(commit.Author.When)">@Age(commit.Author.When)</td> |
| 75 |
<td class="sha dim"><a href="@CommitLink(commit.Sha)">@commit.ShortSha</a></td> |
| 76 |
<td class="wide"> |
| 77 |
<a href="@CommitLink(commit.Sha)" class="subject">@commit.Summary</a> |
| 78 |
@foreach (var name in commit.Refs) |
| 79 |
{ |
| 80 |
<span class="ref @(name == info.Head ? "head" : null)">@name</span> |
| 81 |
} |
| 82 |
</td> |
| 83 |
<td class="dim when-wide">@commit.Author.Name</td> |
| 84 |
</tr> |
| 85 |
} |
| 86 |
</tbody> |
| 87 |
</table> |
| 88 |
</div> |
| 89 |
</section> |
| 90 |
} |
| 91 |
} |
| 92 |
</main> |
| 93 |
|
| 94 |
@code { |
| 95 |
private const int Recently = 15; |
| 96 |
|
| 97 |
private GitRepoSummary? Info { get; set; } |
| 98 |
|
| 99 |
private GitRefsView? Refs { get; set; } |
| 100 |
|
| 101 |
private IReadOnlyList<GitCommitInfo> Recent { get; set; } = []; |
| 102 |
|
| 103 |
protected override void OnParametersSet() |
| 104 |
{ |
| 105 |
Info = Service.GetRepository(Repository); |
| 106 |
|
| 107 |
if (Info is null) |
| 108 |
{ |
| 109 |
NotFound(); |
| 110 |
return; |
| 111 |
} |
| 112 |
|
| 113 |
Refs = Service.GetRefs(Repository); |
| 114 |
Recent = Service.GetLog(Repository, Reference, null, 0, Recently)?.Commits ?? []; |
| 115 |
} |
| 116 |
|
| 117 |
private static string Branches(GitRefsView refs) => |
| 118 |
refs.Branches.Count == 1 ? "1 branch" : $"{refs.Branches.Count} branches"; |
| 119 |
|
| 120 |
private static string Tags(GitRefsView refs) => |
| 121 |
refs.Tags.Count == 1 ? "1 tag" : $"{refs.Tags.Count} tags"; |
| 122 |
} |