Repositories

grarr

(mirrored on github)

Wim Looman <wim@nemo157.com>
b6c5b0 Fix warnings
Wim Looman committed at 2016-03-13 21:24:06

Modified src/render/diff.rs

@@ -2,12 +2,12 @@ use std::ascii::AsciiExt;
use std::mem;
use std::path::PathBuf;
use std::cell::RefCell;
use git2::{ self, Commit, Repository };
use git2;
use maud::{ RenderOnce };
use repository_context::RepositoryContext;
renderers! {
DiffCommits(context: &'a RepositoryContext, old_commit: &'a Option<&'a Commit<'a>>, new_commit: &'a git2::Commit<'a>) {
DiffCommits(context: &'a RepositoryContext, old_commit: &'a Option<&'a git2::Commit<'a>>, new_commit: &'a git2::Commit<'a>) {
@match context.repository.diff_tree_to_tree(old_commit.map(|commit| commit.tree().unwrap()).as_ref(), Some(&new_commit.tree().unwrap()), None) {
Ok(ref diff) => ^Diff(context, new_commit, diff),
Err(ref error) => ^super::Error(error),

Modified src/tree_entry.rs

@@ -36,20 +36,19 @@ impl<'a> TreeEntryContext<'a> {
pub fn get_tree_entry<'a>(context: &'a RepositoryContext, path: &'a str) -> IronResult<TreeEntryContext<'a>> {
let referenced_commit = itry!(context.referenced_commit(), status::NotFound);
let tree = itry!(referenced_commit.commit.tree(), status::InternalServerError);
let entry = if path == "" {
itry!(context.repository.find_object(tree.id(), Some(git2::ObjectType::Tree)))
} else {
let tree_entry = itry!(tree.get_path(Path::new(path)), status::NotFound);
itry!(tree_entry.to_object(&context.repository), status::InternalServerError)
};
let id = referenced_commit.commit.id();
let idstr = format!("{}", id);
let reff = referenced_commit.shorthand_or_id().into_owned();
Ok(TreeEntryContext {
entry: entry,
repo_path: &context.path,
entry_path: "/".to_owned() + path,
reff: reff,
reff: referenced_commit.shorthand_or_id().into_owned(),
commit: referenced_commit,
})
}