mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit de8f763fa7f7cbcaf1a0e70ce5049336ae57c38f
parent e87a87359392a71a7a2cba5bde0124a45641023f
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed, 17 Mar 2021 08:45:38 -0700

Add title to tree page

Diffstat:
Msrc/main.rs | 10++++++++--
Mtemplates/tree.html | 1+
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -269,6 +269,7 @@ async fn repo_refs(req: Request<()>) -> tide::Result { struct RepoTreeTemplate<'a> { repo: &'a Repository, tree: Tree<'a>, + spec: &'a str, } async fn repo_tree(req: Request<()>) -> tide::Result { // TODO handle subtrees @@ -281,10 +282,15 @@ async fn repo_tree(req: Request<()>) -> tide::Result { } // TODO accept reference or commit id - let spec = req.param("ref").unwrap_or("HEAD"); + let head = repo.head()?; + let spec = req.param("ref").unwrap_or(head.shorthand().unwrap()); let commit = repo.revparse_single(spec)?.peel_to_commit()?; let tree = commit.tree()?; - let tmpl = RepoTreeTemplate { repo: &repo, tree }; + let tmpl = RepoTreeTemplate { + repo: &repo, + tree, + spec: spec, + }; Ok(tmpl.into()) } diff --git a/templates/tree.html b/templates/tree.html @@ -2,6 +2,7 @@ {% block content %} {% include "repo-navbar.html" %} + <h2>{{ spec }}</h2> <table> {% for entry in tree %} <tr>