Repositories

grarr

(mirrored on github)

Wim Looman <wim@nemo157.com>
6ba18f Fix warnings
Wim Looman committed at 2016-03-10 14:10:18

Modified src/handler/blob.rs

@@ -2,7 +2,6 @@ use super::base::*;
use tree_entry;
use git2;
use std::path::Path;
#[derive(Clone)]
pub struct Blob;

Modified src/handler/tree.rs

@@ -2,7 +2,6 @@ use super::base::*;
use tree_entry;
use git2;
use std::path::Path;
#[derive(Clone)]
pub struct Tree;

Modified src/render/diff.rs

@@ -1,5 +1,4 @@
use std::ascii::AsciiExt;
use std::string::ToString;
use std::mem;
use std::path::PathBuf;
use std::cell::RefCell;
@@ -198,12 +197,12 @@ impl DiffDelta {
fn id(&self) -> String {
self.new_file.as_ref()
.or(self.old_file.as_ref())
.map(|f| f.to_string_lossy())
.map(|s|
s.chars()
.map(|c| if c.is_whitespace() || c == '/' || !c.is_ascii() { '-' } else { c.to_ascii_lowercase() })
.collect())
.unwrap_or("".to_owned())
.map_or(
"".to_owned(),
|f| f.to_string_lossy()
.chars()
.map(|c| if c.is_whitespace() || c == '/' || !c.is_ascii() { '-' } else { c.to_ascii_lowercase() })
.collect())
}
}

Modified src/render/tree.rs

@@ -3,8 +3,6 @@ use std::cmp::{ Ord, PartialOrd, Ordering };
use std::fmt;
use super::fa::{ FA, FAM };
use git2::{ self, ObjectType };
use std::path::{ self, Path, Component };
use referenced_commit::ReferencedCommit;
use tree_entry::TreeEntryContext;
renderers! {
@@ -47,7 +45,7 @@ renderers! {
div.block-header {
h2 {
^FAM::FixedWidth(FA::File) " "
span.path ^Components(context, false)
span.path ^Components(context)
" at "
^super::Reference(&context.commit)
}
@@ -70,7 +68,7 @@ renderers! {
div.block-header {
h2 {
^FAM::FixedWidth(FA::File) " "
span.path ^Components(context, true)
span.path ^Components(context)
" at "
^super::Reference(&context.commit)
}
@@ -93,17 +91,18 @@ renderers! {
}
}
pub struct Components<'a>(pub &'a TreeEntryContext<'a>, pub bool);
pub struct Components<'a>(pub &'a TreeEntryContext<'a>);
impl<'a> ::maud::RenderOnce for Components<'a> {
#[cfg_attr(feature = "clippy", allow(cyclomatic_complexity))]
fn render_once(self, mut w: &mut fmt::Write) -> fmt::Result {
let Components(context, is_blob) = self;
let context = self.0;
let is_blob = context.entry.kind() == Some(ObjectType::Blob);
try!(html!(w, { a.path-component href={ "/" ^context.repo_path "/tree/" ^context.reff } ^context.repo_path }));
let mut parent = "/".to_owned();
let components: Vec<_> = context.entry_path.split_terminator('/').collect();
for i in 0..components.len() {
let component = components[i];
if component == "" {
for (i, component) in components.iter().enumerate() {
if *component == "" {
continue;
} else if is_blob && i == components.len() - 1 {
try!(html!(w, { "/" a.path-component href={ "/" ^context.repo_path "/blob/" ^context.reff ^parent ^component } ^component }));