mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-27 03:22:15 +03:00
move reference module from core to its own crate
This commit is contained in:
parent
07c6d38378
commit
de200c8e20
19
Cargo.lock
generated
19
Cargo.lock
generated
@ -2110,6 +2110,7 @@ dependencies = [
|
||||
"bstr",
|
||||
"git2",
|
||||
"gitbutler-core",
|
||||
"gitbutler-reference",
|
||||
"hex",
|
||||
"itertools 0.13.0",
|
||||
"lazy_static",
|
||||
@ -2126,6 +2127,7 @@ dependencies = [
|
||||
"gitbutler-branch",
|
||||
"gitbutler-core",
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"itertools 0.13.0",
|
||||
"serde",
|
||||
"toml 0.8.14",
|
||||
@ -2304,6 +2306,17 @@ dependencies = [
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitbutler-reference"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"git2",
|
||||
"gitbutler-core",
|
||||
"regex",
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitbutler-repo"
|
||||
version = "0.0.0"
|
||||
@ -2317,6 +2330,7 @@ dependencies = [
|
||||
"gitbutler-core",
|
||||
"gitbutler-git",
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-testsupport",
|
||||
"gitbutler-user",
|
||||
"log",
|
||||
@ -2341,6 +2355,7 @@ dependencies = [
|
||||
"gitbutler-core",
|
||||
"gitbutler-oplog",
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-user",
|
||||
"itertools 0.13.0",
|
||||
"tracing",
|
||||
@ -2364,6 +2379,7 @@ dependencies = [
|
||||
"gitbutler-feedback",
|
||||
"gitbutler-oplog",
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-repo",
|
||||
"gitbutler-testsupport",
|
||||
"gitbutler-user",
|
||||
@ -2403,6 +2419,7 @@ dependencies = [
|
||||
"gitbutler-command-context",
|
||||
"gitbutler-core",
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-repo",
|
||||
"gitbutler-user",
|
||||
"gitbutler-virtual",
|
||||
@ -2443,6 +2460,7 @@ dependencies = [
|
||||
"gitbutler-git",
|
||||
"gitbutler-oplog",
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-repo",
|
||||
"gitbutler-testsupport",
|
||||
"gitbutler-user",
|
||||
@ -2475,6 +2493,7 @@ dependencies = [
|
||||
"gitbutler-notify-debouncer",
|
||||
"gitbutler-oplog",
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-sync",
|
||||
"gitbutler-user",
|
||||
"gitbutler-virtual",
|
||||
|
@ -18,6 +18,7 @@ members = [
|
||||
"crates/gitbutler-project",
|
||||
"crates/gitbutler-user",
|
||||
"crates/gitbutler-branch",
|
||||
"crates/gitbutler-reference",
|
||||
]
|
||||
resolver = "2"
|
||||
|
||||
@ -47,6 +48,7 @@ gitbutler-config = { path = "crates/gitbutler-config" }
|
||||
gitbutler-project = { path = "crates/gitbutler-project" }
|
||||
gitbutler-user = { path = "crates/gitbutler-user" }
|
||||
gitbutler-branch = { path = "crates/gitbutler-branch" }
|
||||
gitbutler-reference = { path = "crates/gitbutler-reference" }
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
|
||||
|
@ -9,6 +9,7 @@ publish = false
|
||||
anyhow = "1.0.86"
|
||||
git2.workspace = true
|
||||
gitbutler-core.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
itertools = "0.13"
|
||||
serde = { workspace = true, features = ["std"]}
|
||||
bstr = "1.9.1"
|
||||
|
@ -1,13 +1,10 @@
|
||||
use anyhow::Result;
|
||||
use gitbutler_reference::{normalize_branch_name, Refname, RemoteRefname, VirtualRefname};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use gitbutler_core::{
|
||||
git::{self},
|
||||
id::Id,
|
||||
};
|
||||
use gitbutler_core::id::Id;
|
||||
|
||||
use crate::ownership::BranchOwnershipClaims;
|
||||
use gitbutler_core::git::normalize_branch_name;
|
||||
|
||||
pub type BranchId = Id<Branch>;
|
||||
|
||||
@ -20,8 +17,8 @@ pub struct Branch {
|
||||
pub id: BranchId,
|
||||
pub name: String,
|
||||
pub notes: String,
|
||||
pub source_refname: Option<git::Refname>,
|
||||
pub upstream: Option<git::RemoteRefname>,
|
||||
pub source_refname: Option<Refname>,
|
||||
pub upstream: Option<RemoteRefname>,
|
||||
// upstream_head is the last commit on we've pushed to the upstream branch
|
||||
#[serde(with = "gitbutler_core::serde::oid_opt", default)]
|
||||
pub upstream_head: Option<git2::Oid>,
|
||||
@ -78,12 +75,12 @@ where
|
||||
}
|
||||
|
||||
impl Branch {
|
||||
pub fn refname(&self) -> git::VirtualRefname {
|
||||
pub fn refname(&self) -> VirtualRefname {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Branch> for git::VirtualRefname {
|
||||
impl From<&Branch> for VirtualRefname {
|
||||
fn from(value: &Branch) -> Self {
|
||||
Self {
|
||||
branch: normalize_branch_name(&value.name),
|
||||
|
@ -8,8 +8,8 @@ pub mod target;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
lazy_static! {
|
||||
pub static ref GITBUTLER_INTEGRATION_REFERENCE: gitbutler_core::git::LocalRefname =
|
||||
gitbutler_core::git::LocalRefname::new("gitbutler/integration", None);
|
||||
pub static ref GITBUTLER_INTEGRATION_REFERENCE: gitbutler_reference::LocalRefname =
|
||||
gitbutler_reference::LocalRefname::new("gitbutler/integration", None);
|
||||
}
|
||||
|
||||
pub const GITBUTLER_INTEGRATION_COMMIT_AUTHOR_NAME: &str = "GitButler";
|
||||
|
@ -1,10 +1,9 @@
|
||||
use gitbutler_reference::RemoteRefname;
|
||||
use serde::{ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
use gitbutler_core::git;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Target {
|
||||
pub branch: git::RemoteRefname,
|
||||
pub branch: RemoteRefname,
|
||||
pub remote_url: String,
|
||||
pub sha: git2::Oid,
|
||||
pub push_remote_name: Option<String>,
|
||||
@ -43,7 +42,7 @@ impl<'de> serde::Deserialize<'de> for Target {
|
||||
.map_err(|x| serde::de::Error::custom(x.message()))?;
|
||||
|
||||
let target = Target {
|
||||
branch: git::RemoteRefname::new(&target_data.remote_name, &target_data.branch_name),
|
||||
branch: RemoteRefname::new(&target_data.remote_name, &target_data.branch_name),
|
||||
remote_url: target_data.remote_url,
|
||||
sha,
|
||||
push_remote_name: target_data.push_remote_name,
|
||||
|
@ -13,3 +13,4 @@ toml = "0.8.13"
|
||||
serde = { workspace = true, features = ["std"]}
|
||||
gitbutler-project.workspace = true
|
||||
gitbutler-branch.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
|
@ -9,8 +9,9 @@ use gitbutler_branch::{
|
||||
branch::{Branch, BranchId},
|
||||
target::Target,
|
||||
};
|
||||
use gitbutler_core::{error::Code, fs::read_toml_file_or_default, git};
|
||||
use gitbutler_core::{error::Code, fs::read_toml_file_or_default};
|
||||
use gitbutler_project::Project;
|
||||
use gitbutler_reference::Refname;
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -125,7 +126,7 @@ impl VirtualBranchesHandle {
|
||||
|
||||
pub fn find_by_source_refname_where_not_in_workspace(
|
||||
&self,
|
||||
refname: &git::Refname,
|
||||
refname: &Refname,
|
||||
) -> Result<Option<Branch>> {
|
||||
self.list_all_branches().map(|branches| {
|
||||
branches.into_iter().find(|branch| {
|
||||
|
@ -1,6 +1,3 @@
|
||||
mod reference;
|
||||
pub use reference::*;
|
||||
|
||||
mod url;
|
||||
pub use self::url::*;
|
||||
|
||||
|
13
crates/gitbutler-reference/Cargo.toml
Normal file
13
crates/gitbutler-reference/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "gitbutler-reference"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
authors = ["GitButler <gitbutler@gitbutler.com>"]
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
regex = "1.10"
|
||||
git2.workspace = true
|
||||
gitbutler-core.workspace = true
|
||||
serde = { workspace = true, features = ["std"]}
|
||||
thiserror.workspace = true
|
@ -22,6 +22,7 @@ gitbutler-command-context.workspace = true
|
||||
gitbutler-config.workspace = true
|
||||
gitbutler-project.workspace = true
|
||||
gitbutler-branch.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
|
||||
[[test]]
|
||||
name="repo"
|
||||
|
@ -9,6 +9,7 @@ use gitbutler_core::{
|
||||
git::{self, CommitHeadersV2},
|
||||
ssh,
|
||||
};
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
|
||||
use crate::{askpass, Config};
|
||||
use gitbutler_project::AuthKey;
|
||||
@ -20,7 +21,7 @@ pub trait RepoActions {
|
||||
fn push(
|
||||
&self,
|
||||
head: &git2::Oid,
|
||||
branch: &git::RemoteRefname,
|
||||
branch: &RemoteRefname,
|
||||
with_force: bool,
|
||||
credentials: &Helper,
|
||||
refspec: Option<String>,
|
||||
@ -58,7 +59,7 @@ impl RepoActions for ProjectRepo {
|
||||
askpass: Option<Option<BranchId>>,
|
||||
) -> Result<()> {
|
||||
let target_branch_refname =
|
||||
git::Refname::from_str(&format!("refs/remotes/{}/{}", remote_name, branch_name))?;
|
||||
Refname::from_str(&format!("refs/remotes/{}/{}", remote_name, branch_name))?;
|
||||
let branch = self
|
||||
.repo()
|
||||
.find_branch_by_refname(&target_branch_refname)?
|
||||
@ -70,7 +71,7 @@ impl RepoActions for ProjectRepo {
|
||||
let branch_name = format!("test-push-{now}");
|
||||
|
||||
let refname =
|
||||
git::RemoteRefname::from_str(&format!("refs/remotes/{remote_name}/{branch_name}",))?;
|
||||
RemoteRefname::from_str(&format!("refs/remotes/{remote_name}/{branch_name}",))?;
|
||||
|
||||
match self.push(&commit_id, &refname, false, credentials, None, askpass) {
|
||||
Ok(()) => Ok(()),
|
||||
@ -248,7 +249,7 @@ impl RepoActions for ProjectRepo {
|
||||
fn push(
|
||||
&self,
|
||||
head: &git2::Oid,
|
||||
branch: &git::RemoteRefname,
|
||||
branch: &RemoteRefname,
|
||||
with_force: bool,
|
||||
credentials: &Helper,
|
||||
refspec: Option<String>,
|
||||
|
@ -2,12 +2,13 @@ use anyhow::{anyhow, bail, Context, Result};
|
||||
use bstr::BString;
|
||||
use git2::{BlameOptions, Repository, Tree};
|
||||
use gitbutler_config::git::{GbConfig, GitConfig};
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use std::{path::Path, process::Stdio, str};
|
||||
use tracing::instrument;
|
||||
|
||||
use gitbutler_core::error::Code;
|
||||
|
||||
use gitbutler_core::git::{CommitBuffer, CommitHeadersV2, Refname, RemoteRefname};
|
||||
use gitbutler_core::git::{CommitBuffer, CommitHeadersV2};
|
||||
use std::io::Write;
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
@ -17,3 +17,4 @@ gitbutler-command-context.workspace = true
|
||||
gitbutler-project.workspace = true
|
||||
gitbutler-user.workspace = true
|
||||
gitbutler-branch.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
|
@ -7,12 +7,12 @@ use gitbutler_branch::target::Target;
|
||||
use gitbutler_branchstate::VirtualBranchesAccess;
|
||||
use gitbutler_command_context::ProjectRepo;
|
||||
use gitbutler_core::error::Code;
|
||||
use gitbutler_core::git;
|
||||
use gitbutler_core::git::Url;
|
||||
use gitbutler_core::id::Id;
|
||||
use gitbutler_oplog::oplog::Oplog;
|
||||
use gitbutler_project as projects;
|
||||
use gitbutler_project::{CodePushState, Project};
|
||||
use gitbutler_reference::Refname;
|
||||
use gitbutler_user as users;
|
||||
use itertools::Itertools;
|
||||
|
||||
@ -138,7 +138,7 @@ fn batch_rev_walk(
|
||||
Ok(oids)
|
||||
}
|
||||
|
||||
fn collect_refs(project_repository: &ProjectRepo) -> anyhow::Result<Vec<git::Refname>> {
|
||||
fn collect_refs(project_repository: &ProjectRepo) -> anyhow::Result<Vec<Refname>> {
|
||||
Ok(project_repository
|
||||
.repo()
|
||||
.references_glob("refs/*")?
|
||||
@ -161,7 +161,7 @@ fn push_all_refs(
|
||||
.filter(|r| {
|
||||
matches!(
|
||||
r,
|
||||
git::Refname::Remote(_) | git::Refname::Virtual(_) | git::Refname::Local(_)
|
||||
Refname::Remote(_) | Refname::Virtual(_) | Refname::Local(_)
|
||||
)
|
||||
})
|
||||
.map(|r| format!("+{}:{}", r, r))
|
||||
|
@ -57,6 +57,7 @@ gitbutler-config.workspace = true
|
||||
gitbutler-project.workspace = true
|
||||
gitbutler-user.workspace = true
|
||||
gitbutler-branch.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
open = "5"
|
||||
|
||||
[dependencies.tauri]
|
||||
|
@ -1,9 +1,9 @@
|
||||
use anyhow::{Context, Result};
|
||||
use gitbutler_branch::branch::BranchId;
|
||||
use gitbutler_command_context::ProjectRepo;
|
||||
use gitbutler_core::git;
|
||||
use gitbutler_project as projects;
|
||||
use gitbutler_project::ProjectId;
|
||||
use gitbutler_reference::RemoteRefname;
|
||||
use gitbutler_repo::{credentials::Helper, RepoActions, RepositoryExt};
|
||||
use gitbutler_virtual::conflicts;
|
||||
|
||||
@ -25,7 +25,7 @@ impl App {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn git_remote_branches(&self, project_id: ProjectId) -> Result<Vec<git::RemoteRefname>> {
|
||||
pub fn git_remote_branches(&self, project_id: ProjectId) -> Result<Vec<RemoteRefname>> {
|
||||
let project = self.projects.get(project_id)?;
|
||||
let project_repository = ProjectRepo::open(&project)?;
|
||||
project_repository.repo().remote_branches()
|
||||
|
@ -1,5 +1,5 @@
|
||||
use gitbutler_core::git;
|
||||
use gitbutler_project::ProjectId;
|
||||
use gitbutler_reference::RemoteRefname;
|
||||
use gitbutler_repo::credentials::Helper;
|
||||
use tauri::Manager;
|
||||
use tracing::instrument;
|
||||
@ -12,7 +12,7 @@ use crate::error::Error;
|
||||
pub async fn git_remote_branches(
|
||||
handle: tauri::AppHandle,
|
||||
project_id: ProjectId,
|
||||
) -> Result<Vec<git::RemoteRefname>, Error> {
|
||||
) -> Result<Vec<RemoteRefname>, Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
let branches = app.git_remote_branches(project_id)?;
|
||||
Ok(branches)
|
||||
|
@ -3,9 +3,10 @@ pub mod commands {
|
||||
use anyhow::{anyhow, Context};
|
||||
use gitbutler_branch::branch::{BranchCreateRequest, BranchId, BranchUpdateRequest};
|
||||
use gitbutler_branch::ownership::BranchOwnershipClaims;
|
||||
use gitbutler_core::{error::Code, git, types::ReferenceName};
|
||||
use gitbutler_core::{error::Code, types::ReferenceName};
|
||||
use gitbutler_project as projects;
|
||||
use gitbutler_project::ProjectId;
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_virtual::assets;
|
||||
use gitbutler_virtual::base::BaseBranch;
|
||||
use gitbutler_virtual::files::RemoteBranchFile;
|
||||
@ -76,7 +77,7 @@ pub mod commands {
|
||||
pub async fn create_virtual_branch_from_branch(
|
||||
handle: AppHandle,
|
||||
project_id: ProjectId,
|
||||
branch: git::Refname,
|
||||
branch: Refname,
|
||||
) -> Result<BranchId, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_id = handle
|
||||
@ -278,7 +279,7 @@ pub mod commands {
|
||||
pub async fn can_apply_remote_branch(
|
||||
handle: AppHandle,
|
||||
project_id: ProjectId,
|
||||
branch: git::RemoteRefname,
|
||||
branch: RemoteRefname,
|
||||
) -> Result<bool, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
Ok(handle
|
||||
@ -442,7 +443,7 @@ pub mod commands {
|
||||
pub async fn get_remote_branch_data(
|
||||
handle: tauri::AppHandle,
|
||||
project_id: ProjectId,
|
||||
refname: git::Refname,
|
||||
refname: Refname,
|
||||
) -> Result<RemoteBranchData, Error> {
|
||||
let project = handle.state::<projects::Controller>().get(project_id)?;
|
||||
let branch_data = handle
|
||||
|
@ -25,3 +25,4 @@ gitbutler-command-context.workspace = true
|
||||
gitbutler-project.workspace = true
|
||||
gitbutler-user.workspace = true
|
||||
gitbutler-branch.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
|
@ -2,6 +2,7 @@ use std::path::PathBuf;
|
||||
use std::{fs, path};
|
||||
|
||||
use gitbutler_core::git;
|
||||
use gitbutler_reference::{LocalRefname, Refname};
|
||||
use gitbutler_repo::RepositoryExt;
|
||||
use tempfile::TempDir;
|
||||
|
||||
@ -94,7 +95,7 @@ impl TestProject {
|
||||
self.local_repository.workdir().unwrap()
|
||||
}
|
||||
|
||||
pub fn push_branch(&self, branch: &git::LocalRefname) {
|
||||
pub fn push_branch(&self, branch: &LocalRefname) {
|
||||
let mut origin = self.local_repository.find_remote("origin").unwrap();
|
||||
origin.push(&[&format!("{branch}:{branch}")], None).unwrap();
|
||||
}
|
||||
@ -138,12 +139,10 @@ impl TestProject {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn rebase_and_merge(&self, branch_name: &git::Refname) {
|
||||
let branch_name: git::Refname = match branch_name {
|
||||
git::Refname::Local(local) => format!("refs/heads/{}", local.branch()).parse().unwrap(),
|
||||
git::Refname::Remote(remote) => {
|
||||
format!("refs/heads/{}", remote.branch()).parse().unwrap()
|
||||
}
|
||||
pub fn rebase_and_merge(&self, branch_name: &Refname) {
|
||||
let branch_name: Refname = match branch_name {
|
||||
Refname::Local(local) => format!("refs/heads/{}", local.branch()).parse().unwrap(),
|
||||
Refname::Remote(remote) => format!("refs/heads/{}", remote.branch()).parse().unwrap(),
|
||||
_ => "INVALID".parse().unwrap(), // todo
|
||||
};
|
||||
let branch = self
|
||||
@ -153,7 +152,7 @@ impl TestProject {
|
||||
let branch_commit = branch.unwrap().get().peel_to_commit().unwrap();
|
||||
|
||||
let master_branch = {
|
||||
let name: git::Refname = "refs/heads/master".parse().unwrap();
|
||||
let name: Refname = "refs/heads/master".parse().unwrap();
|
||||
self.remote_repository
|
||||
.find_branch_by_refname(&name)
|
||||
.unwrap()
|
||||
@ -217,12 +216,10 @@ impl TestProject {
|
||||
}
|
||||
|
||||
/// works like if we'd open and merge a PR on github. does not update local.
|
||||
pub fn merge(&self, branch_name: &git::Refname) {
|
||||
let branch_name: git::Refname = match branch_name {
|
||||
git::Refname::Local(local) => format!("refs/heads/{}", local.branch()).parse().unwrap(),
|
||||
git::Refname::Remote(remote) => {
|
||||
format!("refs/heads/{}", remote.branch()).parse().unwrap()
|
||||
}
|
||||
pub fn merge(&self, branch_name: &Refname) {
|
||||
let branch_name: Refname = match branch_name {
|
||||
Refname::Local(local) => format!("refs/heads/{}", local.branch()).parse().unwrap(),
|
||||
Refname::Remote(remote) => format!("refs/heads/{}", remote.branch()).parse().unwrap(),
|
||||
_ => "INVALID".parse().unwrap(), // todo
|
||||
};
|
||||
let branch = self
|
||||
@ -232,7 +229,7 @@ impl TestProject {
|
||||
let branch_commit = branch.as_ref().unwrap().get().peel_to_commit().unwrap();
|
||||
|
||||
let master_branch = {
|
||||
let name: git::Refname = "refs/heads/master".parse().unwrap();
|
||||
let name: Refname = "refs/heads/master".parse().unwrap();
|
||||
self.remote_repository
|
||||
.find_branch_by_refname(&name)
|
||||
.unwrap()
|
||||
@ -295,8 +292,8 @@ impl TestProject {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn checkout(&self, branch: &git::LocalRefname) {
|
||||
let refname: git::Refname = branch.into();
|
||||
pub fn checkout(&self, branch: &LocalRefname) {
|
||||
let refname: Refname = branch.into();
|
||||
let head_commit = self
|
||||
.local_repository
|
||||
.head()
|
||||
@ -342,7 +339,7 @@ impl TestProject {
|
||||
index.write().expect("failed to write index");
|
||||
let oid = index.write_tree().expect("failed to write tree");
|
||||
let signature = git2::Signature::now("test", "test@email.com").unwrap();
|
||||
let refname: git::Refname = head.name().unwrap().parse().unwrap();
|
||||
let refname: Refname = head.name().unwrap().parse().unwrap();
|
||||
let repo: &git2::Repository = &self.local_repository;
|
||||
repo.commit_with_signature(
|
||||
Some(&refname),
|
||||
|
@ -16,6 +16,7 @@ gitbutler-branchstate.workspace = true
|
||||
gitbutler-repo.workspace = true
|
||||
gitbutler-user.workspace = true
|
||||
gitbutler-branch.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
serde = { workspace = true, features = ["std"]}
|
||||
bstr = "1.9.1"
|
||||
diffy = "0.3.0"
|
||||
|
@ -9,6 +9,7 @@ use gitbutler_branch::target::Target;
|
||||
use gitbutler_branchstate::{VirtualBranchesAccess, VirtualBranchesHandle};
|
||||
use gitbutler_command_context::ProjectRepo;
|
||||
use gitbutler_project::FetchResult;
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_repo::{LogUntil, RepoActions, RepositoryExt};
|
||||
use serde::Serialize;
|
||||
|
||||
@ -20,7 +21,6 @@ use crate::remote::{commit_to_remote_commit, RemoteCommit};
|
||||
use crate::VirtualBranchHunk;
|
||||
use gitbutler_branch::GITBUTLER_INTEGRATION_REFERENCE;
|
||||
use gitbutler_core::error::Marker;
|
||||
use gitbutler_core::git;
|
||||
use gitbutler_repo::rebase::cherry_rebase;
|
||||
|
||||
#[derive(Debug, Serialize, PartialEq, Clone)]
|
||||
@ -115,7 +115,7 @@ fn go_back_to_integration(
|
||||
|
||||
pub fn set_base_branch(
|
||||
project_repository: &ProjectRepo,
|
||||
target_branch_ref: &git::RemoteRefname,
|
||||
target_branch_ref: &RemoteRefname,
|
||||
) -> Result<BaseBranch> {
|
||||
let repo = project_repository.repo();
|
||||
|
||||
@ -174,7 +174,7 @@ pub fn set_base_branch(
|
||||
vb_state.set_default_target(target.clone())?;
|
||||
|
||||
// TODO: make sure this is a real branch
|
||||
let head_name: git::Refname = current_head
|
||||
let head_name: Refname = current_head
|
||||
.name()
|
||||
.map(|name| name.parse().expect("libgit2 provides valid refnames"))
|
||||
.context("Failed to get HEAD reference name")?;
|
||||
@ -208,12 +208,12 @@ pub fn set_base_branch(
|
||||
|
||||
let now_ms = gitbutler_core::time::now_ms();
|
||||
|
||||
let (upstream, upstream_head) = if let git::Refname::Local(head_name) = &head_name {
|
||||
let (upstream, upstream_head) = if let Refname::Local(head_name) = &head_name {
|
||||
let upstream_name = target_branch_ref.with_branch(head_name.branch());
|
||||
if upstream_name.eq(target_branch_ref) {
|
||||
(None, None)
|
||||
} else {
|
||||
match repo.find_reference(&git::Refname::from(&upstream_name).to_string()) {
|
||||
match repo.find_reference(&Refname::from(&upstream_name).to_string()) {
|
||||
Ok(upstream) => {
|
||||
let head = upstream
|
||||
.peel_to_commit()
|
||||
|
@ -13,6 +13,7 @@ use gitbutler_oplog::{
|
||||
snapshot::Snapshot,
|
||||
};
|
||||
use gitbutler_project::{FetchResult, Project};
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_repo::{credentials::Helper, RepoActions, RepositoryExt};
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
@ -30,7 +31,6 @@ use super::r#virtual as branch;
|
||||
|
||||
use crate::files::RemoteBranchFile;
|
||||
use gitbutler_branch::target;
|
||||
use gitbutler_core::git;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Controller {
|
||||
@ -79,7 +79,7 @@ impl Controller {
|
||||
pub async fn can_apply_remote_branch(
|
||||
&self,
|
||||
project: &Project,
|
||||
branch_name: &git::RemoteRefname,
|
||||
branch_name: &RemoteRefname,
|
||||
) -> Result<bool> {
|
||||
let project_repository = ProjectRepo::open(project)?;
|
||||
branch::is_remote_branch_mergeable(&project_repository, branch_name).map_err(Into::into)
|
||||
@ -110,7 +110,7 @@ impl Controller {
|
||||
pub async fn create_virtual_branch_from_branch(
|
||||
&self,
|
||||
project: &Project,
|
||||
branch: &git::Refname,
|
||||
branch: &Refname,
|
||||
) -> Result<BranchId> {
|
||||
self.permit(project.ignore_project_semaphore).await;
|
||||
|
||||
@ -136,7 +136,7 @@ impl Controller {
|
||||
pub async fn set_base_branch(
|
||||
&self,
|
||||
project: &Project,
|
||||
target_branch: &git::RemoteRefname,
|
||||
target_branch: &RemoteRefname,
|
||||
) -> Result<BaseBranch> {
|
||||
let project_repository = ProjectRepo::open(project)?;
|
||||
let _ = project_repository
|
||||
@ -397,7 +397,7 @@ impl Controller {
|
||||
pub async fn get_remote_branch_data(
|
||||
&self,
|
||||
project: &Project,
|
||||
refname: &git::Refname,
|
||||
refname: &Refname,
|
||||
) -> Result<RemoteBranchData> {
|
||||
let project_repository = ProjectRepo::open(project)?;
|
||||
get_branch_data(&project_repository, refname)
|
||||
|
@ -4,11 +4,12 @@ use anyhow::{Context, Result};
|
||||
use bstr::BString;
|
||||
use gitbutler_branchstate::VirtualBranchesHandle;
|
||||
use gitbutler_command_context::ProjectRepo;
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_repo::{LogUntil, RepoActions, RepositoryExt};
|
||||
use serde::Serialize;
|
||||
|
||||
use gitbutler_branch::target;
|
||||
use gitbutler_core::git::{self, CommitExt};
|
||||
use gitbutler_core::git::CommitExt;
|
||||
|
||||
use crate::author::Author;
|
||||
|
||||
@ -26,8 +27,8 @@ use crate::author::Author;
|
||||
pub struct RemoteBranch {
|
||||
#[serde(with = "gitbutler_core::serde::oid")]
|
||||
pub sha: git2::Oid,
|
||||
pub name: git::Refname,
|
||||
pub upstream: Option<git::RemoteRefname>,
|
||||
pub name: Refname,
|
||||
pub upstream: Option<RemoteRefname>,
|
||||
pub last_commit_timestamp_ms: Option<u128>,
|
||||
pub last_commit_author: Option<String>,
|
||||
}
|
||||
@ -37,8 +38,8 @@ pub struct RemoteBranch {
|
||||
pub struct RemoteBranchData {
|
||||
#[serde(with = "gitbutler_core::serde::oid")]
|
||||
pub sha: git2::Oid,
|
||||
pub name: git::Refname,
|
||||
pub upstream: Option<git::RemoteRefname>,
|
||||
pub name: Refname,
|
||||
pub upstream: Option<RemoteRefname>,
|
||||
pub behind: u32,
|
||||
pub commits: Vec<RemoteCommit>,
|
||||
#[serde(with = "gitbutler_core::serde::oid_opt", default)]
|
||||
@ -89,7 +90,7 @@ pub fn list_remote_branches(project_repository: &ProjectRepo) -> Result<Vec<Remo
|
||||
|
||||
pub fn get_branch_data(
|
||||
project_repository: &ProjectRepo,
|
||||
refname: &git::Refname,
|
||||
refname: &Refname,
|
||||
) -> Result<RemoteBranchData> {
|
||||
let default_target = default_target(&project_repository.project().gb_dir())?;
|
||||
|
||||
@ -114,7 +115,7 @@ pub fn branch_to_remote_branch(branch: &git2::Branch) -> Result<Option<RemoteBra
|
||||
return Ok(None);
|
||||
}
|
||||
};
|
||||
let name = git::Refname::try_from(branch).context("could not get branch name");
|
||||
let name = Refname::try_from(branch).context("could not get branch name");
|
||||
match name {
|
||||
Ok(name) => branch
|
||||
.get()
|
||||
@ -122,7 +123,7 @@ pub fn branch_to_remote_branch(branch: &git2::Branch) -> Result<Option<RemoteBra
|
||||
.map(|sha| {
|
||||
Ok(RemoteBranch {
|
||||
sha,
|
||||
upstream: if let git::Refname::Local(local_name) = &name {
|
||||
upstream: if let Refname::Local(local_name) = &name {
|
||||
local_name.remote().cloned()
|
||||
} else {
|
||||
None
|
||||
@ -158,7 +159,7 @@ pub fn branch_to_remote_branch_data(
|
||||
.log(sha, LogUntil::Commit(base))
|
||||
.context("failed to get ahead commits")?;
|
||||
|
||||
let name = git::Refname::try_from(branch).context("could not get branch name")?;
|
||||
let name = Refname::try_from(branch).context("could not get branch name")?;
|
||||
|
||||
let count_behind = project_repository
|
||||
.distance(base, sha)
|
||||
@ -168,7 +169,7 @@ pub fn branch_to_remote_branch_data(
|
||||
|
||||
Ok(RemoteBranchData {
|
||||
sha,
|
||||
upstream: if let git::Refname::Local(local_name) = &name {
|
||||
upstream: if let Refname::Local(local_name) = &name {
|
||||
local_name.remote().cloned()
|
||||
} else {
|
||||
None
|
||||
|
@ -6,6 +6,7 @@ use gitbutler_branch::ownership::{reconcile_claims, BranchOwnershipClaims};
|
||||
use gitbutler_branchstate::{VirtualBranchesAccess, VirtualBranchesHandle};
|
||||
use gitbutler_command_context::ProjectRepo;
|
||||
use gitbutler_oplog::snapshot::Snapshot;
|
||||
use gitbutler_reference::{normalize_branch_name, Refname, RemoteRefname};
|
||||
use gitbutler_repo::credentials::Helper;
|
||||
use gitbutler_repo::{LogUntil, RepoActions, RepositoryExt};
|
||||
use std::borrow::Borrow;
|
||||
@ -32,14 +33,11 @@ use crate::conflicts::{self, RepoConflicts};
|
||||
use crate::integration::{get_integration_commiter, get_workspace_head};
|
||||
use crate::remote::{branch_to_remote_branch, RemoteBranch};
|
||||
use gitbutler_branch::target;
|
||||
use gitbutler_core::dedup::{dedup, dedup_fmt};
|
||||
use gitbutler_core::error::Code;
|
||||
use gitbutler_core::error::Marker;
|
||||
use gitbutler_core::git::{normalize_branch_name, CommitExt, CommitHeadersV2, HasCommitHeaders};
|
||||
use gitbutler_core::git::{CommitExt, CommitHeadersV2, HasCommitHeaders};
|
||||
use gitbutler_core::time::now_since_unix_epoch_ms;
|
||||
use gitbutler_core::{
|
||||
dedup::{dedup, dedup_fmt},
|
||||
git::{self, Refname, RemoteRefname},
|
||||
};
|
||||
use gitbutler_repo::rebase::{cherry_rebase, cherry_rebase_group};
|
||||
|
||||
type AppliedStatuses = Vec<(branch::Branch, BranchStatus)>;
|
||||
@ -377,7 +375,7 @@ pub fn convert_to_real_branch(
|
||||
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
let branch = repo.branch(&branch_name, &target_commit, true)?;
|
||||
vbranch.source_refname = Some(git::Refname::try_from(&branch)?);
|
||||
vbranch.source_refname = Some(Refname::try_from(&branch)?);
|
||||
vb_state.set_branch(vbranch.clone())?;
|
||||
|
||||
build_metadata_commit(project_repository, vbranch, &branch)?;
|
||||
@ -533,7 +531,7 @@ pub fn list_virtual_branches(
|
||||
update_conflict_markers(project_repository, &files)?;
|
||||
|
||||
let upstream_branch = match branch.clone().upstream {
|
||||
Some(upstream) => repo.find_branch_by_refname(&git::Refname::from(upstream))?,
|
||||
Some(upstream) => repo.find_branch_by_refname(&Refname::from(upstream))?,
|
||||
None => None,
|
||||
};
|
||||
|
||||
@ -1126,7 +1124,7 @@ pub fn update_branch(
|
||||
upstream_remote,
|
||||
normalize_branch_name(updated_upstream)
|
||||
)
|
||||
.parse::<git::RemoteRefname>()
|
||||
.parse::<RemoteRefname>()
|
||||
.unwrap();
|
||||
branch.upstream = Some(remote_branch);
|
||||
};
|
||||
@ -2135,7 +2133,7 @@ pub fn push(
|
||||
upstream_remote,
|
||||
normalize_branch_name(&vbranch.name)
|
||||
)
|
||||
.parse::<git::RemoteRefname>()
|
||||
.parse::<RemoteRefname>()
|
||||
.context("failed to parse remote branch name")?;
|
||||
|
||||
let remote_branches = project_repository.repo().remote_branches()?;
|
||||
@ -2244,7 +2242,7 @@ fn is_commit_integrated(
|
||||
|
||||
pub fn is_remote_branch_mergeable(
|
||||
project_repository: &ProjectRepo,
|
||||
branch_name: &git::RemoteRefname,
|
||||
branch_name: &RemoteRefname,
|
||||
) -> Result<bool> {
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
|
||||
@ -3152,7 +3150,7 @@ pub fn move_commit(
|
||||
|
||||
pub fn create_virtual_branch_from_branch(
|
||||
project_repository: &ProjectRepo,
|
||||
upstream: &git::Refname,
|
||||
upstream: &Refname,
|
||||
) -> Result<BranchId> {
|
||||
fn apply_branch(project_repository: &ProjectRepo, branch_id: BranchId) -> Result<String> {
|
||||
project_repository.assure_resolved()?;
|
||||
@ -3395,12 +3393,12 @@ pub fn create_virtual_branch_from_branch(
|
||||
|
||||
// only set upstream if it's not the default target
|
||||
let upstream_branch = match upstream {
|
||||
git::Refname::Other(_) | git::Refname::Virtual(_) => {
|
||||
Refname::Other(_) | Refname::Virtual(_) => {
|
||||
// we only support local or remote branches
|
||||
bail!("branch {upstream} must be a local or remote branch");
|
||||
}
|
||||
git::Refname::Remote(remote) => Some(remote.clone()),
|
||||
git::Refname::Local(local) => local.remote().cloned(),
|
||||
Refname::Remote(remote) => Some(remote.clone()),
|
||||
Refname::Local(local) => local.remote().cloned(),
|
||||
};
|
||||
|
||||
let branch_name = upstream
|
||||
@ -3416,7 +3414,7 @@ pub fn create_virtual_branch_from_branch(
|
||||
|
||||
let default_target = vb_state.get_default_target()?;
|
||||
|
||||
if let git::Refname::Remote(remote_upstream) = upstream {
|
||||
if let Refname::Remote(remote_upstream) = upstream {
|
||||
if default_target.branch == *remote_upstream {
|
||||
bail!("cannot create a branch from default target")
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use gitbutler_branch::{
|
||||
};
|
||||
use gitbutler_branchstate::VirtualBranchesAccess;
|
||||
use gitbutler_core::git::{self, CommitExt};
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_repo::RepositoryExt;
|
||||
use gitbutler_virtual::integration;
|
||||
use gitbutler_virtual::r#virtual as virtual_branches;
|
||||
@ -692,7 +693,7 @@ fn commit_id_can_be_generated_or_specified() -> Result<()> {
|
||||
let oid = index.write_tree().expect("failed to write tree");
|
||||
let signature = git2::Signature::now("test", "test@email.com").unwrap();
|
||||
let head = repository.head().expect("failed to get head");
|
||||
let refname: git::Refname = head.name().unwrap().parse().unwrap();
|
||||
let refname: Refname = head.name().unwrap().parse().unwrap();
|
||||
project_repository
|
||||
.repo()
|
||||
.commit_with_signature(
|
||||
@ -789,7 +790,7 @@ fn merge_vbranch_upstream_clean_rebase() -> Result<()> {
|
||||
// Update integration commit
|
||||
integration::update_gitbutler_integration(&vb_state, project_repository)?;
|
||||
|
||||
let remote_branch: git::RemoteRefname = "refs/remotes/origin/master".parse().unwrap();
|
||||
let remote_branch: RemoteRefname = "refs/remotes/origin/master".parse().unwrap();
|
||||
let mut branch = create_virtual_branch(project_repository, &BranchCreateRequest::default())
|
||||
.expect("failed to create virtual branch");
|
||||
branch.upstream = Some(remote_branch.clone());
|
||||
@ -886,7 +887,7 @@ async fn merge_vbranch_upstream_conflict() -> Result<()> {
|
||||
"line1\nline2\nline3\nline4\nupstream\nother side\n",
|
||||
)?;
|
||||
|
||||
let remote_branch: git::RemoteRefname = "refs/remotes/origin/master".parse().unwrap();
|
||||
let remote_branch: RemoteRefname = "refs/remotes/origin/master".parse().unwrap();
|
||||
let mut branch = create_virtual_branch(project_repository, &BranchCreateRequest::default())
|
||||
.expect("failed to create virtual branch");
|
||||
branch.upstream = Some(remote_branch.clone());
|
||||
@ -1077,7 +1078,7 @@ fn unapply_branch() -> Result<()> {
|
||||
|
||||
let branch1_id = virtual_branches::create_virtual_branch_from_branch(
|
||||
project_repository,
|
||||
&git::Refname::try_from(&real_branch)?,
|
||||
&Refname::try_from(&real_branch)?,
|
||||
)?;
|
||||
let contents = std::fs::read(Path::new(&project.path).join(file_path))?;
|
||||
assert_eq!(
|
||||
@ -1165,7 +1166,7 @@ fn apply_unapply_added_deleted_files() -> Result<()> {
|
||||
|
||||
create_virtual_branch_from_branch(
|
||||
project_repository,
|
||||
&git::Refname::try_from(&real_branch_2).unwrap(),
|
||||
&Refname::try_from(&real_branch_2).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -1174,7 +1175,7 @@ fn apply_unapply_added_deleted_files() -> Result<()> {
|
||||
|
||||
create_virtual_branch_from_branch(
|
||||
project_repository,
|
||||
&git::Refname::try_from(&real_branch_3).unwrap(),
|
||||
&Refname::try_from(&real_branch_3).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
use gitbutler_reference::Refname;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
@ -67,7 +69,7 @@ async fn rebase_commit() {
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(&unapplied_branch).unwrap()
|
||||
Refname::from_str(&unapplied_branch).unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
@ -171,7 +173,7 @@ async fn rebase_work() {
|
||||
assert!(!repository.path().join("another_file.txt").exists());
|
||||
assert!(!repository.path().join("file.txt").exists());
|
||||
|
||||
git::Refname::from_str(&unapplied_branch).unwrap()
|
||||
Refname::from_str(&unapplied_branch).unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
|
@ -1,3 +1,5 @@
|
||||
use gitbutler_reference::Refname;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
@ -73,7 +75,7 @@ async fn conflicting() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
git::Refname::from_str(&unapplied_branch).unwrap()
|
||||
Refname::from_str(&unapplied_branch).unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
|
@ -1,3 +1,5 @@
|
||||
use gitbutler_reference::LocalRefname;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
@ -131,7 +133,7 @@ async fn no_conflicts() {
|
||||
|
||||
{
|
||||
// create a remote branch
|
||||
let branch_name: git::LocalRefname = "refs/heads/branch".parse().unwrap();
|
||||
let branch_name: LocalRefname = "refs/heads/branch".parse().unwrap();
|
||||
repository.checkout(&branch_name);
|
||||
fs::write(repository.path().join("file.txt"), "first").unwrap();
|
||||
repository.commit_all("first");
|
||||
@ -170,7 +172,7 @@ async fn conflicts_with_uncommited() {
|
||||
|
||||
{
|
||||
// create a remote branch
|
||||
let branch_name: git::LocalRefname = "refs/heads/branch".parse().unwrap();
|
||||
let branch_name: LocalRefname = "refs/heads/branch".parse().unwrap();
|
||||
repository.checkout(&branch_name);
|
||||
fs::write(repository.path().join("file.txt"), "first").unwrap();
|
||||
repository.commit_all("first");
|
||||
@ -221,7 +223,7 @@ async fn conflicts_with_commited() {
|
||||
|
||||
{
|
||||
// create a remote branch
|
||||
let branch_name: git::LocalRefname = "refs/heads/branch".parse().unwrap();
|
||||
let branch_name: LocalRefname = "refs/heads/branch".parse().unwrap();
|
||||
repository.checkout(&branch_name);
|
||||
fs::write(repository.path().join("file.txt"), "first").unwrap();
|
||||
repository.commit_all("first");
|
||||
@ -333,7 +335,7 @@ async fn from_state_remote_branch() {
|
||||
|
||||
{
|
||||
// create a remote branch
|
||||
let branch_name: git::LocalRefname = "refs/heads/branch".parse().unwrap();
|
||||
let branch_name: LocalRefname = "refs/heads/branch".parse().unwrap();
|
||||
repository.checkout(&branch_name);
|
||||
fs::write(repository.path().join("file.txt"), "branch commit").unwrap();
|
||||
repository.commit_all("branch commit");
|
||||
|
@ -5,6 +5,7 @@ use gitbutler_branch::branch;
|
||||
use gitbutler_core::error::Marker;
|
||||
use gitbutler_core::git;
|
||||
use gitbutler_project::{self as projects, Project, ProjectId};
|
||||
use gitbutler_reference::Refname;
|
||||
use gitbutler_virtual::Controller;
|
||||
use tempfile::TempDir;
|
||||
|
||||
@ -131,7 +132,7 @@ async fn resolve_conflict_flow() {
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(&unapplied_branches[0]).unwrap()
|
||||
Refname::from_str(&unapplied_branches[0]).unwrap()
|
||||
};
|
||||
|
||||
let branch1_id = {
|
||||
|
@ -373,7 +373,7 @@ async fn applying_first_branch() {
|
||||
.convert_to_real_branch(project, branches[0].id, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let unapplied_branch = git::Refname::from_str(&unapplied_branch).unwrap();
|
||||
let unapplied_branch = Refname::from_str(&unapplied_branch).unwrap();
|
||||
controller
|
||||
.create_virtual_branch_from_branch(project, &unapplied_branch)
|
||||
.await
|
||||
|
@ -15,6 +15,8 @@ async fn success() {
|
||||
}
|
||||
|
||||
mod error {
|
||||
use gitbutler_reference::RemoteRefname;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
@ -29,7 +31,7 @@ mod error {
|
||||
controller
|
||||
.set_base_branch(
|
||||
project,
|
||||
&git::RemoteRefname::from_str("refs/remotes/origin/missing").unwrap(),
|
||||
&RemoteRefname::from_str("refs/remotes/origin/missing").unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap_err()
|
||||
|
@ -48,7 +48,7 @@ mod applied_branch {
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
@ -118,7 +118,7 @@ mod applied_branch {
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
@ -194,7 +194,7 @@ mod applied_branch {
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
@ -267,7 +267,7 @@ mod applied_branch {
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
@ -340,7 +340,7 @@ mod applied_branch {
|
||||
let (branches, _) = controller.list_virtual_branches(project).await.unwrap();
|
||||
assert_eq!(branches.len(), 0);
|
||||
|
||||
git::Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
Refname::from_str(unapplied_branches[0].as_str()).unwrap()
|
||||
};
|
||||
|
||||
{
|
||||
@ -765,7 +765,7 @@ mod applied_branch {
|
||||
controller
|
||||
.create_virtual_branch_from_branch(
|
||||
project,
|
||||
&git::Refname::from_str(unapplied_refname.as_str()).unwrap(),
|
||||
&Refname::from_str(unapplied_refname.as_str()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -1,3 +1,5 @@
|
||||
use gitbutler_reference::LocalRefname;
|
||||
|
||||
use super::*;
|
||||
|
||||
// Ensures that `verify_branch` returns an error when not on the integration branch.
|
||||
@ -10,7 +12,7 @@ async fn should_fail_on_incorrect_branch() {
|
||||
..
|
||||
} = &Test::default();
|
||||
|
||||
let branch_name: git::LocalRefname = "refs/heads/somebranch".parse().unwrap();
|
||||
let branch_name: LocalRefname = "refs/heads/somebranch".parse().unwrap();
|
||||
repository.checkout(&branch_name);
|
||||
let result = controller.list_virtual_branches(project).await;
|
||||
|
||||
|
@ -23,6 +23,7 @@ gix = { workspace = true, features = ["excludes"] }
|
||||
gitbutler-command-context.workspace = true
|
||||
gitbutler-project.workspace = true
|
||||
gitbutler-user.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
|
||||
|
||||
backoff = "0.4.0"
|
||||
|
@ -4,13 +4,13 @@ use std::sync::Arc;
|
||||
use anyhow::{Context, Result};
|
||||
use gitbutler_command_context::ProjectRepo;
|
||||
use gitbutler_core::error::Marker;
|
||||
use gitbutler_core::git;
|
||||
use gitbutler_oplog::{
|
||||
entry::{OperationKind, SnapshotDetails},
|
||||
oplog::Oplog,
|
||||
};
|
||||
use gitbutler_project as projects;
|
||||
use gitbutler_project::ProjectId;
|
||||
use gitbutler_reference::{LocalRefname, Refname};
|
||||
use gitbutler_sync::cloud::sync_with_gitbutler;
|
||||
use gitbutler_user as users;
|
||||
use gitbutler_virtual::assets;
|
||||
@ -184,11 +184,8 @@ impl Handler {
|
||||
let head_ref_name = head_ref.name().context("failed to get head name")?;
|
||||
if head_ref_name != "refs/heads/gitbutler/integration" {
|
||||
let mut integration_reference = project_repository.repo().find_reference(
|
||||
&git::Refname::from(git::LocalRefname::new(
|
||||
"gitbutler/integration",
|
||||
None,
|
||||
))
|
||||
.to_string(),
|
||||
&Refname::from(LocalRefname::new("gitbutler/integration", None))
|
||||
.to_string(),
|
||||
)?;
|
||||
integration_reference.delete()?;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user