Fix branch
parent: tbd commit: ff70fd4
Showing 1 changed file with 11 insertions and 3 deletions
giterated-daemon/src/backend/git.rs
@@ -2,6 +2,7 @@ use anyhow::Error; | ||
2 | 2 | use async_trait::async_trait; |
3 | 3 | use futures_util::StreamExt; |
4 | 4 | |
5 | use git2::BranchType; | |
5 | 6 | use giterated_models::instance::{Instance, RepositoryCreateRequest}; |
6 | 7 | |
7 | 8 | use giterated_models::repository::{ |
@@ -572,10 +573,17 @@ impl RepositoryBackend for GitBackend { | ||
572 | 573 | } |
573 | 574 | }; |
574 | 575 | |
575 | // If the reference wasn't found, try parsing it as a commit ID and otherwise return error | |
576 | // If the reference wasn't found, try parsing it as a commit ID | |
576 | 577 | if tree_id.is_none() { |
577 | match git2::Oid::from_str(request.rev.as_ref().unwrap()) { | |
578 | Ok(oid) => tree_id = Some(oid), | |
578 | if let Ok(oid) = git2::Oid::from_str(request.rev.as_ref().unwrap()) { | |
579 | tree_id = Some(oid) | |
580 | } | |
581 | } | |
582 | ||
583 | // If the commit ID wasn't found, try parsing it as a branch and otherwise return error | |
584 | if tree_id.is_none() { | |
585 | match git.find_branch(request.rev.as_ref().unwrap(), BranchType::Local) { | |
586 | Ok(branch) => tree_id = branch.get().target(), | |
579 | 587 | Err(_) => { |
580 | 588 | return Err(Box::new(GitBackendError::RefNotFound( |
581 | 589 | request.rev.clone().unwrap(), |