mygit

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

commit 0c222c73e0089863966ede93e963b1674ff03afe
parent e1a180eafd9a87ea90ab1f9948d36b118417bc42
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Sat,  3 Apr 2021 11:06:18 +0200

remove unnecessary HEAD fallback

The requests handled by this function will always have a :ref parameter,
so the HEAD fallback would never be used.

Diffstat:
Msrc/main.rs | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -439,14 +439,15 @@ struct RepoFileTemplate<'a> { } async fn repo_file(req: Request<()>) -> tide::Result { - // TODO rename for clarity let repo = repo_from_request(req.param("repo_name")?)?; - let head = repo.head()?; - let spec = req.param("ref").ok().or_else(|| head.shorthand()).unwrap(); + + let spec = req.param("ref").unwrap(); let commit = repo.revparse_single(spec)?.peel_to_commit()?; let tree = commit.tree()?; + let path = Path::new(req.param("object_name")?); let tree_entry = tree.get_path(path).unwrap(); + // TODO make sure I am escaping html properly here // TODO allow disabling of syntax highlighting // TODO -- dont pull in memory, use iterators if possible