@page "/git/{Repository}/log" @inherits GitPage @Repository log โ€” git
@if (Page is not { } page) {

@(BranchNames.Count == 0 ? $"Nothing has been pushed to {Repository} yet." : $"No revision called {Reference ?? "HEAD"} in {Repository}.")

} else {

log @Where

@* A plain GET form: the log is a URL, and narrowing it should produce one you can link to. Nothing here needs script. *@
@if (page.Commits.Count == 0) {

No commits@(string.IsNullOrEmpty(Path) ? "" : $" touching {Path}").

} else {
@foreach (var commit in page.Commits) { }
age commit subject author
@Age(commit.Author.When) @commit.ShortSha @commit.Summary @if (commit.IsMerge) { merge } @foreach (var name in commit.Refs) { @name } @commit.Author.Name
@if (Skip > 0) { newer } else { newest } @if (page.HasMore) { older } else { oldest }
}
}
@code { private const int PageSize = 50; /// Narrows the log to the commits that touched one file or directory. [SupplyParameterFromQuery(Name = "path")] public string? Path { get; set; } /// How many commits to skip โ€” the offset cgit paged with, under the name it used. [SupplyParameterFromQuery(Name = "ofs")] public int Skip { get; set; } private GitLogPage? Page { get; set; } private IReadOnlyList BranchNames { get; set; } = []; /// The branch this page is of, which is HEAD's when the query string named none. private string? Current { get; set; } private string Where => string.IsNullOrEmpty(Path) ? Current ?? "" : $"{Current} ยท {Path}"; protected override void OnParametersSet() { Skip = Math.Max(0, Skip); // GetRefs lists HEAD's branch first, so the picker's first entry is also what this page // defaults to โ€” one repository open rather than two. if (Service.GetRefs(Repository) is not { } refs) { NotFound(); return; } BranchNames = refs.Branches.Select(branch => branch.Name).ToArray(); Current = Reference ?? BranchNames.FirstOrDefault(); Page = Service.GetLog(Repository, Reference, Path, Skip, PageSize); // A repository with branches but nothing at this revision was reached by a bad URL. One // with no branches at all is a repository nobody has pushed to, which is not an error. if (Page is null && BranchNames.Count > 0) NotFound(); } }