rm some accidentally duplicated code

This commit is contained in:
Kiril Videlov 2024-06-05 14:41:09 +02:00
parent f4ec31f81b
commit 665ab4952a
2 changed files with 9 additions and 21 deletions

View File

@ -9,7 +9,7 @@ use anyhow::{anyhow, Context, Result};
use super::conflicts;
use crate::{
askpass,
git::{self, Refname, Url},
git::{self, Url},
projects::{self, AuthKey},
ssh, users,
virtual_branches::{Branch, BranchId},
@ -151,15 +151,11 @@ impl Repository {
) -> Result<()> {
let target_branch_refname =
git::Refname::from_str(&format!("refs/remotes/{}/{}", remote_name, branch_name))?;
let branch = self.git_repository.find_branch(
&target_branch_refname.simple_name(),
match target_branch_refname {
Refname::Virtual(_) | Refname::Local(_) | Refname::Other(_) => {
git2::BranchType::Local
}
Refname::Remote(_) => git2::BranchType::Remote,
},
)?;
let branch = self
.git_repository
.find_branch_by_refname(&target_branch_refname)?
.ok_or(anyhow!("failed to find branch {}", target_branch_refname))?;
let commit_id: Oid = branch.get().peel_to_commit()?.id().into();
let now = crate::time::now_ms();

View File

@ -6,7 +6,7 @@ use serde::Serialize;
use super::{target, Author, VirtualBranchesHandle};
use crate::{
git::{self, CommitExt, Refname},
git::{self, CommitExt, RepositoryExt},
project_repository::{self, LogUntil},
};
@ -91,16 +91,8 @@ pub fn get_branch_data(
let branch = project_repository
.repo()
.find_branch(
&refname.simple_name(),
match refname {
Refname::Virtual(_) | Refname::Local(_) | Refname::Other(_) => {
git2::BranchType::Local
}
Refname::Remote(_) => git2::BranchType::Remote,
},
)
.context(format!("failed to find branch with refname {refname}"))?;
.find_branch_by_refname(refname)?
.ok_or(anyhow::anyhow!("failed to find branch {}", refname))?;
branch_to_remote_branch_data(project_repository, &branch, default_target.sha)?
.context("failed to get branch data")