diff options
Diffstat (limited to 'src/get_routes.rs')
-rw-r--r-- | src/get_routes.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/get_routes.rs b/src/get_routes.rs index ec46feb..95d535d 100644 --- a/src/get_routes.rs +++ b/src/get_routes.rs @@ -55,7 +55,7 @@ fn view_blob<C: Controller>( parts: &Parts, ) -> Result<Response, Error> { let mut page = Page { - title: ctx.file_name().unwrap().to_owned(), + title: ctx.path.file_name().unwrap().to_owned(), header: action_links(¶ms.action, controller, &ctx, parts), ..Default::default() }; @@ -131,7 +131,7 @@ fn log_blob<C: Controller>( ctx: Context, parts: &Parts, ) -> Result<Response, Error> { - let filename = ctx.file_name().unwrap(); + let filename = ctx.path.file_name().unwrap(); let mut page = Page { title: format!("Log for {}", filename), @@ -144,14 +144,14 @@ fn log_blob<C: Controller>( walk.push(branch_head.id())?; let mut prev_commit = branch_head; - let mut prev_blobid = Some(prev_commit.tree()?.get_path(&ctx.path)?.id()); + let mut prev_blobid = Some(prev_commit.tree()?.get_path(&ctx.path.as_ref())?.id()); let mut commits = Vec::new(); // TODO: paginate for oid in walk.flatten().skip(1) { let commit = ctx.repo.find_commit(oid)?; - if let Ok(entr) = commit.tree()?.get_path(&ctx.path) { + if let Ok(entr) = commit.tree()?.get_path(&ctx.path.as_ref()) { let blobid = entr.id(); if Some(blobid) != prev_blobid { commits.push(prev_commit); @@ -166,7 +166,7 @@ fn log_blob<C: Controller>( prev_blobid = None; } } - if prev_commit.parent_count() == 0 && prev_commit.tree()?.get_path(&ctx.path).is_ok() { + if prev_commit.parent_count() == 0 && prev_commit.tree()?.get_path(&ctx.path.as_ref()).is_ok() { // the very first commit of the branch commits.push(prev_commit); } @@ -249,11 +249,11 @@ fn diff_blob<C: Controller>( commit.parents().next() }; - let blob_id = if let Ok(entry) = commit.tree()?.get_path(&ctx.path) { + let blob_id = if let Ok(entry) = commit.tree()?.get_path(&ctx.path.as_ref()) { entry.id() } else { return Ok(Page { - title: format!("Commit for {}", ctx.file_name().unwrap()), + title: format!("Commit for {}", ctx.path.file_name().unwrap()), body: "file removed".into(), header: action_links(&action_param.action, controller, &ctx, parts), ..Default::default() @@ -262,7 +262,7 @@ fn diff_blob<C: Controller>( }; let old_blob_id = old_commit - .and_then(|p| p.tree().unwrap().get_path(&ctx.path).ok()) + .and_then(|p| p.tree().unwrap().get_path(&ctx.path.as_ref()).ok()) .map(|e| e.id()); if Some(blob_id) == old_blob_id { @@ -277,7 +277,7 @@ fn diff_blob<C: Controller>( } else { "Commit" }, - ctx.file_name().unwrap() + ctx.path.file_name().unwrap() ), header: action_links(&action_param.action, controller, &ctx, parts), ..Default::default() @@ -362,7 +362,7 @@ fn run_blob<C: Controller>( ctx: Context, parts: &Parts, ) -> Result<HyperResponse, Error> { - if ctx.path.extension().unwrap().to_str() != Some("html") { + if ctx.path.extension() != Some("html") { return Err(Error::BadRequest( "run action only available for .html files".into(), )); @@ -394,12 +394,12 @@ fn move_blob<C: Controller>( )); } - let filename = ctx.file_name().unwrap(); + let filename = ctx.path.file_name().unwrap(); return forms::move_form( filename, &forms::MoveForm { - dest: ctx.path.to_str().unwrap().to_owned(), + dest: ctx.path.as_str().to_owned(), msg: None, }, None, @@ -422,7 +422,7 @@ fn remove_blob<C: Controller>( )); } - let filename = ctx.file_name().unwrap(); + let filename = ctx.path.file_name().unwrap(); let page = Page { title: format!("Remove {}", filename), @@ -444,7 +444,7 @@ pub fn view_tree<C: Controller>( parts: &Parts, ) -> Result<Response, Error> { let mut page = Page { - title: ctx.path.to_string_lossy().to_string(), + title: ctx.path.as_str().to_string(), ..Default::default() }; |