mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-27 11:36:48 +03:00
repo -> repository
This commit is contained in:
parent
f4569ff4da
commit
21bad4f30f
@ -97,7 +97,7 @@ impl VirtualBranchActions {
|
||||
commit_oid: git2::Oid,
|
||||
) -> Result<Vec<RemoteBranchFile>> {
|
||||
let ctx = CommandContext::open(project)?;
|
||||
crate::file::list_remote_commit_files(ctx.repo(), commit_oid).map_err(Into::into)
|
||||
crate::file::list_remote_commit_files(ctx.repository(), commit_oid).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn set_base_branch(
|
||||
@ -404,7 +404,7 @@ impl VirtualBranchActions {
|
||||
let ctx = CommandContext::open(project)?;
|
||||
|
||||
let helper = Helper::default();
|
||||
let remotes = ctx.repo().remotes_as_string()?;
|
||||
let remotes = ctx.repository().remotes_as_string()?;
|
||||
let fetch_errors: Vec<_> = remotes
|
||||
.iter()
|
||||
.filter_map(|remote| {
|
||||
|
@ -49,7 +49,7 @@ pub(crate) fn get_base_branch_data(ctx: &CommandContext) -> Result<BaseBranch> {
|
||||
|
||||
fn go_back_to_integration(ctx: &CommandContext, default_target: &Target) -> Result<BaseBranch> {
|
||||
let statuses = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.statuses(Some(
|
||||
git2::StatusOptions::new()
|
||||
.show(git2::StatusShow::IndexAndWorkdir)
|
||||
@ -66,7 +66,7 @@ fn go_back_to_integration(ctx: &CommandContext, default_target: &Target) -> Resu
|
||||
.context("failed to read virtual branches")?;
|
||||
|
||||
let target_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(default_target.sha)
|
||||
.context("failed to find target commit")?;
|
||||
|
||||
@ -79,26 +79,26 @@ fn go_back_to_integration(ctx: &CommandContext, default_target: &Target) -> Resu
|
||||
for branch in &virtual_branches {
|
||||
// merge this branches tree with our tree
|
||||
let branch_head = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(branch.head)
|
||||
.context("failed to find branch head")?;
|
||||
let branch_tree = branch_head
|
||||
.tree()
|
||||
.context("failed to get branch head tree")?;
|
||||
let mut result = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.merge_trees(&base_tree, &final_tree, &branch_tree, None)
|
||||
.context("failed to merge")?;
|
||||
let final_tree_oid = result
|
||||
.write_tree_to(ctx.repo())
|
||||
.write_tree_to(ctx.repository())
|
||||
.context("failed to write tree")?;
|
||||
final_tree = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_tree(final_tree_oid)
|
||||
.context("failed to find written tree")?;
|
||||
}
|
||||
|
||||
ctx.repo()
|
||||
ctx.repository()
|
||||
.checkout_tree_builder(&final_tree)
|
||||
.force()
|
||||
.checkout()
|
||||
@ -113,7 +113,7 @@ pub(crate) fn set_base_branch(
|
||||
ctx: &CommandContext,
|
||||
target_branch_ref: &RemoteRefname,
|
||||
) -> Result<BaseBranch> {
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
|
||||
// if target exists, and it is the same as the requested branch, we should go back
|
||||
if let Ok(target) = default_target(&ctx.project().gb_dir()) {
|
||||
@ -267,7 +267,7 @@ pub(crate) fn set_base_branch(
|
||||
|
||||
pub(crate) fn set_target_push_remote(ctx: &CommandContext, push_remote_name: &str) -> Result<()> {
|
||||
let remote = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_remote(push_remote_name)
|
||||
.context(format!("failed to find remote {}", push_remote_name))?;
|
||||
|
||||
@ -285,7 +285,7 @@ pub(crate) fn set_target_push_remote(ctx: &CommandContext, push_remote_name: &st
|
||||
}
|
||||
|
||||
fn set_exclude_decoration(ctx: &CommandContext) -> Result<()> {
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
let mut config = repo.config()?;
|
||||
config
|
||||
.set_multivar("log.excludeDecoration", "refs/gitbutler", "refs/gitbutler")
|
||||
@ -327,7 +327,7 @@ pub(crate) fn update_base_branch(
|
||||
|
||||
// look up the target and see if there is a new oid
|
||||
let target = default_target(&ctx.project().gb_dir())?;
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
let target_branch = repo
|
||||
.find_branch_by_refname(&target.branch.clone().into())
|
||||
.context(format!("failed to find branch {}", target.branch))?;
|
||||
@ -384,7 +384,7 @@ pub(crate) fn update_base_branch(
|
||||
branch.upstream_head = None;
|
||||
|
||||
let non_commited_files =
|
||||
gitbutler_diff::trees(ctx.repo(), &branch_head_tree, &branch_tree)?;
|
||||
gitbutler_diff::trees(ctx.repository(), &branch_head_tree, &branch_tree)?;
|
||||
if non_commited_files.is_empty() {
|
||||
// if there are no commited files, then the branch is fully merged
|
||||
// and we can delete it.
|
||||
@ -417,7 +417,7 @@ pub(crate) fn update_base_branch(
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let branch_merge_index_tree_oid = branch_tree_merge_index.write_tree_to(ctx.repo())?;
|
||||
let branch_merge_index_tree_oid = branch_tree_merge_index.write_tree_to(ctx.repository())?;
|
||||
|
||||
if branch_merge_index_tree_oid == new_target_tree.id() {
|
||||
return result_integrated_detected(branch);
|
||||
@ -451,7 +451,7 @@ pub(crate) fn update_base_branch(
|
||||
|
||||
// branch commits do not conflict with new target, so lets merge them
|
||||
let branch_head_merge_tree_oid = branch_head_merge_index
|
||||
.write_tree_to(ctx.repo())
|
||||
.write_tree_to(ctx.repository())
|
||||
.context(format!(
|
||||
"failed to write head merge index for {}",
|
||||
branch.id
|
||||
@ -552,7 +552,7 @@ pub(crate) fn update_base_branch(
|
||||
}
|
||||
|
||||
pub(crate) fn target_to_base_branch(ctx: &CommandContext, target: &Target) -> Result<BaseBranch> {
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
let branch = repo
|
||||
.find_branch_by_refname(&target.branch.clone().into())?
|
||||
.ok_or(anyhow!("failed to get branch"))?;
|
||||
|
@ -33,7 +33,7 @@ pub fn list_branches(
|
||||
_ => None,
|
||||
});
|
||||
let mut git_branches: Vec<GroupBranch> = vec![];
|
||||
for result in ctx.repo().branches(branch_filter)? {
|
||||
for result in ctx.repository().branches(branch_filter)? {
|
||||
match result {
|
||||
Ok((branch, branch_type)) => match branch_type {
|
||||
git2::BranchType::Local => {
|
||||
@ -101,7 +101,7 @@ fn combine_branches(
|
||||
ctx: &CommandContext,
|
||||
vb_handle: &VirtualBranchesHandle,
|
||||
) -> Result<Vec<BranchListing>> {
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
for branch in virtual_branches {
|
||||
group_branches.push(GroupBranch::Virtual(branch));
|
||||
}
|
||||
@ -396,7 +396,7 @@ pub fn get_branch_listing_details(
|
||||
ctx: &CommandContext,
|
||||
branch_names: Vec<String>,
|
||||
) -> Result<Vec<BranchListingDetails>> {
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
// Can we do this in a more efficient way?
|
||||
let branches = list_branches(ctx, None)?
|
||||
.into_iter()
|
||||
|
@ -30,7 +30,7 @@ impl BranchManager<'_> {
|
||||
|
||||
let commit = self
|
||||
.ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(default_target.sha)
|
||||
.context("failed to find default target commit")?;
|
||||
|
||||
@ -165,7 +165,7 @@ impl BranchManager<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
let repo = self.ctx.repo();
|
||||
let repo = self.ctx.repository();
|
||||
let head_reference = repo
|
||||
.find_reference(&target.to_string())
|
||||
.map_err(|err| match err {
|
||||
@ -200,7 +200,7 @@ impl BranchManager<'_> {
|
||||
let merge_base_tree = repo.find_commit(merge_base_oid)?.tree()?;
|
||||
|
||||
// do a diff between the head of this branch and the target base
|
||||
let diff = gitbutler_diff::trees(self.ctx.repo(), &merge_base_tree, &head_commit_tree)?;
|
||||
let diff = gitbutler_diff::trees(self.ctx.repository(), &merge_base_tree, &head_commit_tree)?;
|
||||
|
||||
// assign ownership to the branch
|
||||
let ownership = diff.iter().fold(
|
||||
@ -285,7 +285,7 @@ impl BranchManager<'_> {
|
||||
) -> Result<String> {
|
||||
self.ctx.assure_resolved()?;
|
||||
self.ctx.assure_unconflicted()?;
|
||||
let repo = self.ctx.repo();
|
||||
let repo = self.ctx.repository();
|
||||
|
||||
let vb_state = self.ctx.project().virtual_branches();
|
||||
let default_target = vb_state.get_default_target()?;
|
||||
@ -364,7 +364,7 @@ impl BranchManager<'_> {
|
||||
.context("failed to find head commit")?;
|
||||
|
||||
let merged_branch_tree_oid = merge_index
|
||||
.write_tree_to(self.ctx.repo())
|
||||
.write_tree_to(self.ctx.repository())
|
||||
.context("failed to write tree")?;
|
||||
|
||||
let merged_branch_tree = repo
|
||||
@ -451,7 +451,7 @@ impl BranchManager<'_> {
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
}
|
||||
|
||||
let wd_tree = self.ctx.repo().get_wd_tree()?;
|
||||
let wd_tree = self.ctx.repository().get_wd_tree()?;
|
||||
|
||||
let branch_tree = repo
|
||||
.find_tree(branch.tree)
|
||||
|
@ -68,7 +68,7 @@ impl BranchManager<'_> {
|
||||
.project()
|
||||
.snapshot_branch_deletion(branch.name.clone(), perm);
|
||||
|
||||
let repo = self.ctx.repo();
|
||||
let repo = self.ctx.repository();
|
||||
|
||||
let target_commit = repo.target_commit()?;
|
||||
let base_tree = target_commit.tree().context("failed to get target tree")?;
|
||||
@ -125,7 +125,7 @@ impl BranchManager<'_> {
|
||||
|
||||
impl BranchManager<'_> {
|
||||
fn build_real_branch(&self, vbranch: &mut Branch) -> Result<git2::Branch<'_>> {
|
||||
let repo = self.ctx.repo();
|
||||
let repo = self.ctx.repository();
|
||||
let target_commit = repo.find_commit(vbranch.head)?;
|
||||
let branch_name = vbranch.name.clone();
|
||||
let branch_name = normalize_branch_name(&branch_name);
|
||||
@ -145,7 +145,7 @@ impl BranchManager<'_> {
|
||||
vbranch: &mut Branch,
|
||||
branch: &git2::Branch<'_>,
|
||||
) -> Result<Option<git2::Oid>> {
|
||||
let repo = self.ctx.repo();
|
||||
let repo = self.ctx.repository();
|
||||
|
||||
// Build wip tree as either any uncommitted changes or an empty tree
|
||||
let vbranch_wip_tree = repo.find_tree(vbranch.tree)?;
|
||||
|
@ -46,11 +46,11 @@ pub(crate) fn mark<P: AsRef<Path>, A: AsRef<[P]>>(
|
||||
}
|
||||
|
||||
fn conflicts_path(ctx: &CommandContext) -> PathBuf {
|
||||
ctx.repo().path().join("conflicts")
|
||||
ctx.repository().path().join("conflicts")
|
||||
}
|
||||
|
||||
fn merge_parent_path(ctx: &CommandContext) -> PathBuf {
|
||||
ctx.repo().path().join("base_merge_parent")
|
||||
ctx.repository().path().join("base_merge_parent")
|
||||
}
|
||||
|
||||
pub(crate) fn merge_parent(ctx: &CommandContext) -> Result<Option<git2::Oid>> {
|
||||
|
@ -95,7 +95,7 @@ pub(crate) fn list_virtual_commit_files(
|
||||
let parent = commit.parent(0).context("failed to get parent commit")?;
|
||||
let commit_tree = commit.tree().context("failed to get commit tree")?;
|
||||
let parent_tree = parent.tree().context("failed to get parent tree")?;
|
||||
let diff = gitbutler_diff::trees(ctx.repo(), &parent_tree, &commit_tree)?;
|
||||
let diff = gitbutler_diff::trees(ctx.repository(), &parent_tree, &commit_tree)?;
|
||||
let hunks_by_filepath = virtual_hunks_by_file_diffs(&ctx.project().path, diff);
|
||||
Ok(virtual_hunks_into_virtual_files(ctx, hunks_by_filepath))
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ pub(crate) fn get_workspace_head(project_repo: &CommandContext) -> Result<git2::
|
||||
let target = vb_state
|
||||
.get_default_target()
|
||||
.context("failed to get target")?;
|
||||
let repo: &git2::Repository = project_repo.repo();
|
||||
let repo: &git2::Repository = project_repo.repository();
|
||||
|
||||
let mut virtual_branches: Vec<Branch> = vb_state.list_branches_in_workspace()?;
|
||||
|
||||
@ -141,7 +141,7 @@ pub fn update_gitbutler_integration(
|
||||
.get_default_target()
|
||||
.context("failed to get target")?;
|
||||
|
||||
let repo: &git2::Repository = ctx.repo();
|
||||
let repo: &git2::Repository = ctx.repository();
|
||||
|
||||
// get commit object from target.sha
|
||||
let target_commit = repo.find_commit(target.sha)?;
|
||||
@ -288,7 +288,7 @@ pub fn verify_branch(ctx: &CommandContext, perm: &mut WorktreeWritePermission) -
|
||||
}
|
||||
|
||||
fn verify_head_is_set(ctx: &CommandContext) -> Result<()> {
|
||||
match ctx.repo().head().context("failed to get head")?.name() {
|
||||
match ctx.repository().head().context("failed to get head")?.name() {
|
||||
Some(refname) if *refname == GITBUTLER_INTEGRATION_REFERENCE.to_string() => Ok(()),
|
||||
Some(head_name) => Err(invalid_head_err(head_name)),
|
||||
None => Err(anyhow!(
|
||||
@ -300,7 +300,7 @@ fn verify_head_is_set(ctx: &CommandContext) -> Result<()> {
|
||||
|
||||
// Returns an error if repo head is not pointing to the integration branch.
|
||||
fn verify_current_branch_name(ctx: &CommandContext) -> Result<&CommandContext> {
|
||||
match ctx.repo().head()?.name() {
|
||||
match ctx.repository().head()?.name() {
|
||||
Some(head) => {
|
||||
let head_name = head.to_string();
|
||||
if head_name != GITBUTLER_INTEGRATION_REFERENCE.to_string() {
|
||||
@ -315,7 +315,7 @@ fn verify_current_branch_name(ctx: &CommandContext) -> Result<&CommandContext> {
|
||||
// TODO(ST): Probably there should not be an implicit vbranch creation here.
|
||||
fn verify_head_is_clean(ctx: &CommandContext, perm: &mut WorktreeWritePermission) -> Result<()> {
|
||||
let head_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.head()
|
||||
.context("failed to get head")?
|
||||
.peel_to_commit()
|
||||
@ -342,7 +342,7 @@ fn verify_head_is_clean(ctx: &CommandContext, perm: &mut WorktreeWritePermission
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
ctx.repo()
|
||||
ctx.repository()
|
||||
.reset(
|
||||
integration_commit.as_ref().unwrap().as_object(),
|
||||
git2::ResetType::Soft,
|
||||
@ -369,12 +369,12 @@ fn verify_head_is_clean(ctx: &CommandContext, perm: &mut WorktreeWritePermission
|
||||
let mut head = new_branch.head;
|
||||
for commit in extra_commits {
|
||||
let new_branch_head = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(head)
|
||||
.context("failed to find new branch head")?;
|
||||
|
||||
let rebased_commit_oid = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.commit_with_signature(
|
||||
None,
|
||||
&commit.author(),
|
||||
@ -389,7 +389,7 @@ fn verify_head_is_clean(ctx: &CommandContext, perm: &mut WorktreeWritePermission
|
||||
commit.id()
|
||||
))?;
|
||||
|
||||
let rebased_commit = ctx.repo().find_commit(rebased_commit_oid).context(format!(
|
||||
let rebased_commit = ctx.repository().find_commit(rebased_commit_oid).context(format!(
|
||||
"failed to find rebased commit {}",
|
||||
rebased_commit_oid
|
||||
))?;
|
||||
|
@ -66,7 +66,7 @@ pub fn list_remote_branches(ctx: &CommandContext) -> Result<Vec<RemoteBranch>> {
|
||||
|
||||
let mut remote_branches = vec![];
|
||||
for (branch, _) in ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.branches(None)
|
||||
.context("failed to list remote branches")?
|
||||
.flatten()
|
||||
@ -92,7 +92,7 @@ pub(crate) fn get_branch_data(ctx: &CommandContext, refname: &Refname) -> Result
|
||||
let default_target = default_target(&ctx.project().gb_dir())?;
|
||||
|
||||
let branch = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_branch_by_refname(refname)?
|
||||
.ok_or(anyhow::anyhow!("failed to find branch {}", refname))?;
|
||||
|
||||
@ -119,7 +119,7 @@ pub(crate) fn branch_to_remote_branch(
|
||||
.context("could not get branch name")
|
||||
.ok()?;
|
||||
|
||||
let given_name = branch.get().given_name(&ctx.repo().remotes().ok()?).ok()?;
|
||||
let given_name = branch.get().given_name(&ctx.repository().remotes().ok()?).ok()?;
|
||||
|
||||
branch.get().target().map(|sha| RemoteBranch {
|
||||
sha,
|
||||
|
@ -37,7 +37,7 @@ pub fn get_applied_status(
|
||||
.project()
|
||||
.virtual_branches()
|
||||
.list_branches_in_workspace()?;
|
||||
let base_file_diffs = gitbutler_diff::workdir(ctx.repo(), &integration_commit.to_owned())
|
||||
let base_file_diffs = gitbutler_diff::workdir(ctx.repository(), &integration_commit.to_owned())
|
||||
.context("failed to diff workdir")?;
|
||||
|
||||
let mut skipped_files: Vec<gitbutler_diff::FileDiff> = Vec::new();
|
||||
@ -69,7 +69,7 @@ pub fn get_applied_status(
|
||||
.map(|branch| (branch.id, HashMap::new()))
|
||||
.collect();
|
||||
|
||||
let locks = compute_locks(ctx.repo(), &base_diffs, &virtual_branches)?;
|
||||
let locks = compute_locks(ctx.repository(), &base_diffs, &virtual_branches)?;
|
||||
|
||||
for branch in &mut virtual_branches {
|
||||
let old_claims = branch.ownership.claims.clone();
|
||||
|
@ -138,7 +138,7 @@ pub fn unapply_ownership(
|
||||
}
|
||||
}
|
||||
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
|
||||
let target_commit = repo
|
||||
.find_commit(integration_commit_id)
|
||||
@ -158,7 +158,7 @@ pub fn unapply_ownership(
|
||||
gitbutler_diff::write::hunks_onto_oid(ctx, &integration_commit_id, files)?;
|
||||
let branch_tree = repo.find_tree(tree_oid)?;
|
||||
let mut result = repo.merge_trees(&base_tree, &final_tree, &branch_tree, None)?;
|
||||
let final_tree_oid = result.write_tree_to(ctx.repo())?;
|
||||
let final_tree_oid = result.write_tree_to(ctx.repository())?;
|
||||
repo.find_tree(final_tree_oid)
|
||||
.context("failed to find tree")
|
||||
},
|
||||
@ -186,7 +186,7 @@ pub(crate) fn reset_files(ctx: &CommandContext, files: &Vec<String>) -> Result<(
|
||||
|
||||
// for each tree, we need to checkout the entry from the index at that path
|
||||
// or if it doesn't exist, remove the file from the working directory
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
let index = repo.index().context("failed to get index")?;
|
||||
for file in files {
|
||||
let entry = index.get_path(Path::new(file), 0);
|
||||
@ -277,7 +277,7 @@ pub fn list_virtual_branches(
|
||||
.unwrap_or(-1);
|
||||
|
||||
for (branch, mut files) in status.branches {
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
update_conflict_markers(ctx, files.clone())?;
|
||||
|
||||
let upstream_branch = match branch.clone().upstream {
|
||||
@ -422,18 +422,18 @@ fn is_requires_force(ctx: &CommandContext, branch: &Branch) -> Result<bool> {
|
||||
return Ok(false);
|
||||
};
|
||||
|
||||
let reference = match ctx.repo().refname_to_id(&upstream.to_string()) {
|
||||
let reference = match ctx.repository().refname_to_id(&upstream.to_string()) {
|
||||
Ok(reference) => reference,
|
||||
Err(err) if err.code() == git2::ErrorCode::NotFound => return Ok(false),
|
||||
Err(other) => return Err(other).context("failed to find upstream reference"),
|
||||
};
|
||||
|
||||
let upstream_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(reference)
|
||||
.context("failed to find upstream commit")?;
|
||||
|
||||
let merge_base = ctx.repo().merge_base(upstream_commit.id(), branch.head)?;
|
||||
let merge_base = ctx.repository().merge_base(upstream_commit.id(), branch.head)?;
|
||||
|
||||
Ok(merge_base != upstream_commit.id())
|
||||
}
|
||||
@ -466,7 +466,7 @@ fn is_requires_force(ctx: &CommandContext, branch: &Branch) -> Result<bool> {
|
||||
pub fn integrate_upstream_commits(ctx: &CommandContext, branch_id: BranchId) -> Result<()> {
|
||||
conflicts::is_conflicting(ctx, None)?;
|
||||
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
let project = ctx.project();
|
||||
let vb_state = project.virtual_branches();
|
||||
|
||||
@ -557,7 +557,7 @@ pub fn integrate_upstream_commits(ctx: &CommandContext, branch_id: BranchId) ->
|
||||
let new_head_tree = repo.find_commit(new_head)?.tree()?;
|
||||
let head_commit = repo.find_commit(new_head)?;
|
||||
|
||||
let wd_tree = ctx.repo().get_wd_tree()?;
|
||||
let wd_tree = ctx.repository().get_wd_tree()?;
|
||||
let integration_tree = repo.find_commit(get_workspace_head(ctx)?)?.tree()?;
|
||||
|
||||
let mut merge_index = repo.merge_trees(&integration_tree, &new_head_tree, &wd_tree, None)?;
|
||||
@ -595,8 +595,8 @@ pub(crate) fn integrate_with_merge(
|
||||
upstream_commit: &git2::Commit,
|
||||
merge_base: git2::Oid,
|
||||
) -> Result<git2::Oid> {
|
||||
let wd_tree = ctx.repo().get_wd_tree()?;
|
||||
let repo = ctx.repo();
|
||||
let wd_tree = ctx.repository().get_wd_tree()?;
|
||||
let repo = ctx.repository();
|
||||
let remote_tree = upstream_commit.tree().context("failed to get tree")?;
|
||||
let upstream_branch = branch.upstream.as_ref().context("upstream not found")?;
|
||||
// let merge_tree = repo.find_commit(merge_base).and_then(|c| c.tree())?;
|
||||
@ -621,7 +621,7 @@ pub(crate) fn integrate_with_merge(
|
||||
return Err(anyhow!("merge problem")).context(Marker::ProjectConflict);
|
||||
}
|
||||
|
||||
let merge_tree_oid = merge_index.write_tree_to(ctx.repo())?;
|
||||
let merge_tree_oid = merge_index.write_tree_to(ctx.repository())?;
|
||||
let merge_tree = repo.find_tree(merge_tree_oid)?;
|
||||
let head_commit = repo.find_commit(branch.head)?;
|
||||
|
||||
@ -806,7 +806,7 @@ pub(crate) fn reset_branch(
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
let updated_head = get_workspace_head(ctx)?;
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
let diff = trees(
|
||||
repo,
|
||||
&repo
|
||||
@ -857,7 +857,7 @@ pub fn commit(
|
||||
|
||||
if run_hooks {
|
||||
let hook_result =
|
||||
git2_hooks::hooks_commit_msg(ctx.repo(), Some(&["../.husky"]), &mut message_buffer)
|
||||
git2_hooks::hooks_commit_msg(ctx.repository(), Some(&["../.husky"]), &mut message_buffer)
|
||||
.context("failed to run hook")
|
||||
.context(Code::CommitHookFailed)?;
|
||||
|
||||
@ -866,7 +866,7 @@ pub fn commit(
|
||||
.context(Code::CommitHookFailed));
|
||||
}
|
||||
|
||||
let hook_result = git2_hooks::hooks_pre_commit(ctx.repo(), Some(&["../.husky"]))
|
||||
let hook_result = git2_hooks::hooks_pre_commit(ctx.repository(), Some(&["../.husky"]))
|
||||
.context("failed to run hook")
|
||||
.context(Code::CommitHookFailed)?;
|
||||
|
||||
@ -928,7 +928,7 @@ pub fn commit(
|
||||
gitbutler_diff::write::hunks_onto_commit(ctx, branch.head, files)?
|
||||
};
|
||||
|
||||
let git_repository = ctx.repo();
|
||||
let git_repository = ctx.repository();
|
||||
let parent_commit = git_repository
|
||||
.find_commit(branch.head)
|
||||
.context(format!("failed to find commit {:?}", branch.head))?;
|
||||
@ -956,7 +956,7 @@ pub fn commit(
|
||||
};
|
||||
|
||||
if run_hooks {
|
||||
git2_hooks::hooks_post_commit(ctx.repo(), Some(&["../.husky"]))
|
||||
git2_hooks::hooks_post_commit(ctx.repository(), Some(&["../.husky"]))
|
||||
.context("failed to run hook")
|
||||
.context(Code::CommitHookFailed)?;
|
||||
}
|
||||
@ -1000,7 +1000,7 @@ pub(crate) fn push(
|
||||
.parse::<RemoteRefname>()
|
||||
.context("failed to parse remote branch name")?;
|
||||
|
||||
let remote_branches = ctx.repo().remote_branches()?;
|
||||
let remote_branches = ctx.repository().remote_branches()?;
|
||||
let existing_branches = remote_branches
|
||||
.iter()
|
||||
.map(RemoteRefname::branch)
|
||||
@ -1053,14 +1053,14 @@ struct IsCommitIntegrated<'repo> {
|
||||
impl<'repo> IsCommitIntegrated<'repo> {
|
||||
fn new(ctx: &'repo CommandContext, target: &Target) -> anyhow::Result<Self> {
|
||||
let remote_branch = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_branch_by_refname(&target.branch.clone().into())?
|
||||
.ok_or(anyhow!("failed to get branch"))?;
|
||||
let remote_head = remote_branch.get().peel_to_commit()?;
|
||||
let upstream_commits = ctx.l(remote_head.id(), LogUntil::Commit(target.sha))?;
|
||||
let inmemory_repo = ctx.repo().in_memory_repo()?;
|
||||
let inmemory_repo = ctx.repository().in_memory_repo()?;
|
||||
Ok(Self {
|
||||
repo: ctx.repo(),
|
||||
repo: ctx.repository(),
|
||||
target_commit_id: target.sha,
|
||||
remote_head_id: remote_head.id(),
|
||||
upstream_commits,
|
||||
@ -1130,27 +1130,27 @@ pub fn is_remote_branch_mergeable(
|
||||
|
||||
let default_target = vb_state.get_default_target()?;
|
||||
let target_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(default_target.sha)
|
||||
.context("failed to find target commit")?;
|
||||
|
||||
let branch = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_branch_by_refname(&branch_name.into())?
|
||||
.ok_or(anyhow!("branch not found"))?;
|
||||
let branch_oid = branch.get().target().context("detatched head")?;
|
||||
let branch_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(branch_oid)
|
||||
.context("failed to find branch commit")?;
|
||||
|
||||
let base_tree = find_base_tree(ctx.repo(), &branch_commit, &target_commit)?;
|
||||
let base_tree = find_base_tree(ctx.repository(), &branch_commit, &target_commit)?;
|
||||
|
||||
let wd_tree = ctx.repo().get_wd_tree()?;
|
||||
let wd_tree = ctx.repository().get_wd_tree()?;
|
||||
|
||||
let branch_tree = branch_commit.tree().context("failed to find branch tree")?;
|
||||
let mergeable = !ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.merge_trees(&base_tree, &branch_tree, &wd_tree, None)
|
||||
.context("failed to merge trees")?
|
||||
.has_conflicts();
|
||||
@ -1182,7 +1182,7 @@ pub(crate) fn move_commit_file(
|
||||
|
||||
let mut to_amend_oid = to_commit_id;
|
||||
let mut amend_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(to_amend_oid)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
@ -1190,7 +1190,7 @@ pub(crate) fn move_commit_file(
|
||||
let mut upstream_commits = ctx.l(target_branch.head, LogUntil::Commit(amend_commit.id()))?;
|
||||
|
||||
// get a list of all the diffs across all the virtual branches
|
||||
let base_file_diffs = gitbutler_diff::workdir(ctx.repo(), &default_target.sha)
|
||||
let base_file_diffs = gitbutler_diff::workdir(ctx.repository(), &default_target.sha)
|
||||
.context("failed to diff workdir")?;
|
||||
|
||||
// filter base_file_diffs to HashMap<filepath, Vec<GitHunk>> only for hunks in target_ownership
|
||||
@ -1237,7 +1237,7 @@ pub(crate) fn move_commit_file(
|
||||
|
||||
// first, let's get the from commit data and it's parent data
|
||||
let from_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(from_commit_id)
|
||||
.context("failed to find commit")?;
|
||||
let from_tree = from_commit.tree().context("failed to find tree")?;
|
||||
@ -1248,7 +1248,7 @@ pub(crate) fn move_commit_file(
|
||||
// we need to remove the parts of this patch that are in target_ownership (the parts we're moving)
|
||||
// and then apply the rest to the parent tree of the "from" commit to
|
||||
// create the new "from" commit without the changes we're moving
|
||||
let from_commit_diffs = gitbutler_diff::trees(ctx.repo(), &from_parent_tree, &from_tree)
|
||||
let from_commit_diffs = gitbutler_diff::trees(ctx.repository(), &from_parent_tree, &from_tree)
|
||||
.context("failed to diff trees")?;
|
||||
|
||||
// filter from_commit_diffs to HashMap<filepath, Vec<GitHunk>> only for hunks NOT in target_ownership
|
||||
@ -1278,7 +1278,7 @@ pub(crate) fn move_commit_file(
|
||||
})
|
||||
.collect::<HashMap<_, _>>();
|
||||
|
||||
let repo = ctx.repo();
|
||||
let repo = ctx.repository();
|
||||
|
||||
// write our new tree and commit for the new "from" commit without the moved changes
|
||||
let new_from_tree_id =
|
||||
@ -1287,7 +1287,7 @@ pub(crate) fn move_commit_file(
|
||||
.find_tree(new_from_tree_id)
|
||||
.with_context(|| "tree {new_from_tree_oid} not found")?;
|
||||
let new_from_commit_oid = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.commit_with_signature(
|
||||
None,
|
||||
&from_commit.author(),
|
||||
@ -1328,7 +1328,7 @@ pub(crate) fn move_commit_file(
|
||||
|
||||
// reset the "to" commit variable for writing the changes back to
|
||||
amend_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(to_amend_oid)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
@ -1346,12 +1346,12 @@ pub(crate) fn move_commit_file(
|
||||
let new_tree_oid =
|
||||
gitbutler_diff::write::hunks_onto_commit(ctx, to_amend_oid, &diffs_to_amend)?;
|
||||
let new_tree = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_tree(new_tree_oid)
|
||||
.context("failed to find new tree")?;
|
||||
let parents: Vec<_> = amend_commit.parents().collect();
|
||||
let commit_oid = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.commit_with_signature(
|
||||
None,
|
||||
&amend_commit.author(),
|
||||
@ -1431,7 +1431,7 @@ pub(crate) fn amend(
|
||||
|
||||
// find commit oid
|
||||
let amend_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit_oid)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
@ -1470,13 +1470,13 @@ pub(crate) fn amend(
|
||||
// apply diffs_to_amend to the commit tree
|
||||
let new_tree_oid = gitbutler_diff::write::hunks_onto_commit(ctx, commit_oid, &diffs_to_amend)?;
|
||||
let new_tree = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_tree(new_tree_oid)
|
||||
.context("failed to find new tree")?;
|
||||
|
||||
let parents: Vec<_> = amend_commit.parents().collect();
|
||||
let commit_oid = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.commit_with_signature(
|
||||
None,
|
||||
&amend_commit.author(),
|
||||
@ -1529,7 +1529,7 @@ pub(crate) fn reorder_commit(
|
||||
let mut branch = vb_state.get_branch_in_workspace(branch_id)?;
|
||||
// find the commit to offset from
|
||||
let commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit_oid)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
@ -1612,7 +1612,7 @@ pub(crate) fn insert_blank_commit(
|
||||
let mut branch = vb_state.get_branch_in_workspace(branch_id)?;
|
||||
// find the commit to offset from
|
||||
let mut commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit_oid)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
@ -1659,7 +1659,7 @@ pub(crate) fn undo_commit(
|
||||
|
||||
let mut branch = vb_state.get_branch_in_workspace(branch_id)?;
|
||||
let commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit_oid)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
@ -1713,7 +1713,7 @@ pub(crate) fn squash(
|
||||
}
|
||||
|
||||
let commit_to_squash = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit_id)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
@ -1742,7 +1742,7 @@ pub(crate) fn squash(
|
||||
let parents: Vec<_> = parent_commit.parents().collect();
|
||||
|
||||
let new_commit_oid = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.commit_with_signature(
|
||||
None,
|
||||
&commit_to_squash.author(),
|
||||
@ -1816,14 +1816,14 @@ pub(crate) fn update_commit_message(
|
||||
}
|
||||
|
||||
let target_commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit_id)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
let parents: Vec<_> = target_commit.parents().collect();
|
||||
|
||||
let new_commit_oid = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.commit_with_signature(
|
||||
None,
|
||||
&target_commit.author(),
|
||||
@ -1883,7 +1883,7 @@ pub(crate) fn move_commit(
|
||||
let source_branch_non_comitted_files = source_status;
|
||||
|
||||
let source_branch_head = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit_id)
|
||||
.context("failed to find commit")?;
|
||||
let source_branch_head_parent = source_branch_head
|
||||
@ -1896,7 +1896,7 @@ pub(crate) fn move_commit(
|
||||
.tree()
|
||||
.context("failed to get parent tree")?;
|
||||
let branch_head_diff = gitbutler_diff::trees(
|
||||
ctx.repo(),
|
||||
ctx.repository(),
|
||||
&source_branch_head_parent_tree,
|
||||
&source_branch_head_tree,
|
||||
)?;
|
||||
@ -1960,7 +1960,7 @@ pub(crate) fn move_commit(
|
||||
)
|
||||
.context("failed to write tree onto commit")?;
|
||||
let new_destination_tree = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_tree(new_destination_tree_oid)
|
||||
.context("failed to find tree")?;
|
||||
|
||||
@ -1969,7 +1969,7 @@ pub(crate) fn move_commit(
|
||||
&source_branch_head.message_bstr().to_str_lossy(),
|
||||
&new_destination_tree,
|
||||
&[&ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(destination_branch.head)
|
||||
.context("failed to get dst branch head commit")?],
|
||||
source_branch_head.gitbutler_headers(),
|
||||
|
@ -100,7 +100,7 @@ fn track_binary_files() -> Result<()> {
|
||||
];
|
||||
let mut file = std::fs::File::create(Path::new(&project.path).join("image.bin"))?;
|
||||
file.write_all(&image_data)?;
|
||||
commit_all(ctx.repo());
|
||||
commit_all(ctx.repository());
|
||||
|
||||
set_test_target(ctx)?;
|
||||
|
||||
@ -149,9 +149,9 @@ fn track_binary_files() -> Result<()> {
|
||||
// status (no files)
|
||||
let (branches, _) = list_virtual_branches(ctx, guard.write_permission()).unwrap();
|
||||
let commit_id = &branches[0].commits[0].id;
|
||||
let commit_obj = ctx.repo().find_commit(commit_id.to_owned())?;
|
||||
let commit_obj = ctx.repository().find_commit(commit_id.to_owned())?;
|
||||
let tree = commit_obj.tree()?;
|
||||
let files = tree_to_entry_list(ctx.repo(), &tree);
|
||||
let files = tree_to_entry_list(ctx.repository(), &tree);
|
||||
assert_eq!(files[0].0, "image.bin");
|
||||
assert_eq!(
|
||||
files[0].3, img_oid_hex,
|
||||
@ -173,9 +173,9 @@ fn track_binary_files() -> Result<()> {
|
||||
let (branches, _) = list_virtual_branches(ctx, guard.write_permission()).unwrap();
|
||||
let commit_id = &branches[0].commits[0].id;
|
||||
// get tree from commit_id
|
||||
let commit_obj = ctx.repo().find_commit(commit_id.to_owned())?;
|
||||
let commit_obj = ctx.repository().find_commit(commit_id.to_owned())?;
|
||||
let tree = commit_obj.tree()?;
|
||||
let files = tree_to_entry_list(ctx.repo(), &tree);
|
||||
let files = tree_to_entry_list(ctx.repository(), &tree);
|
||||
|
||||
assert_eq!(files[0].0, "image.bin");
|
||||
assert_eq!(files[0].3, "ea6901a04d1eed6ebf6822f4360bda9f008fa317");
|
||||
@ -698,11 +698,11 @@ fn commit_id_can_be_generated_or_specified() -> Result<()> {
|
||||
Path::new(&project.path).join(file_path),
|
||||
"line1\nline2\nline3\nline4\n",
|
||||
)?;
|
||||
commit_all(ctx.repo());
|
||||
commit_all(ctx.repository());
|
||||
|
||||
// lets make sure a change id is generated
|
||||
let target_oid = ctx.repo().head().unwrap().target().unwrap();
|
||||
let target = ctx.repo().find_commit(target_oid).unwrap();
|
||||
let target_oid = ctx.repository().head().unwrap().target().unwrap();
|
||||
let target = ctx.repository().find_commit(target_oid).unwrap();
|
||||
let change_id = target.change_id();
|
||||
|
||||
// make sure we created a change-id
|
||||
@ -715,7 +715,7 @@ fn commit_id_can_be_generated_or_specified() -> Result<()> {
|
||||
"line1\nline2\nline3\nline4\nline5\n",
|
||||
)?;
|
||||
|
||||
let repository = ctx.repo();
|
||||
let repository = ctx.repository();
|
||||
let mut index = repository.index().expect("failed to get index");
|
||||
index
|
||||
.add_all(["."], git2::IndexAddOption::DEFAULT, None)
|
||||
@ -725,7 +725,7 @@ fn commit_id_can_be_generated_or_specified() -> Result<()> {
|
||||
let signature = git2::Signature::now("test", "test@email.com").unwrap();
|
||||
let head = repository.head().expect("failed to get head");
|
||||
let refname: Refname = head.name().unwrap().parse().unwrap();
|
||||
ctx.repo()
|
||||
ctx.repository()
|
||||
.commit_with_signature(
|
||||
Some(&refname),
|
||||
&signature,
|
||||
@ -746,8 +746,8 @@ fn commit_id_can_be_generated_or_specified() -> Result<()> {
|
||||
)
|
||||
.expect("failed to commit");
|
||||
|
||||
let target_oid = ctx.repo().head().unwrap().target().unwrap();
|
||||
let target = ctx.repo().find_commit(target_oid).unwrap();
|
||||
let target_oid = ctx.repository().head().unwrap().target().unwrap();
|
||||
let target = ctx.repository().find_commit(target_oid).unwrap();
|
||||
let change_id = target.change_id();
|
||||
|
||||
// the change id should be what we specified, rather than randomly generated
|
||||
@ -766,16 +766,16 @@ fn merge_vbranch_upstream_clean_rebase() -> Result<()> {
|
||||
Path::new(&project.path).join(file_path),
|
||||
"line1\nline2\nline3\nline4\n",
|
||||
)?;
|
||||
commit_all(ctx.repo());
|
||||
let target_oid = ctx.repo().head().unwrap().target().unwrap();
|
||||
commit_all(ctx.repository());
|
||||
let target_oid = ctx.repository().head().unwrap().target().unwrap();
|
||||
|
||||
std::fs::write(
|
||||
Path::new(&project.path).join(file_path),
|
||||
"line1\nline2\nline3\nline4\nupstream\n",
|
||||
)?;
|
||||
// add a commit to the target branch it's pointing to so there is something "upstream"
|
||||
commit_all(ctx.repo());
|
||||
let last_push = ctx.repo().head().unwrap().target().unwrap();
|
||||
commit_all(ctx.repository());
|
||||
let last_push = ctx.repository().head().unwrap().target().unwrap();
|
||||
|
||||
// coworker adds some work
|
||||
std::fs::write(
|
||||
@ -783,11 +783,11 @@ fn merge_vbranch_upstream_clean_rebase() -> Result<()> {
|
||||
"line1\nline2\nline3\nline4\nupstream\ncoworker work\n",
|
||||
)?;
|
||||
|
||||
commit_all(ctx.repo());
|
||||
let coworker_work = ctx.repo().head().unwrap().target().unwrap();
|
||||
commit_all(ctx.repository());
|
||||
let coworker_work = ctx.repository().head().unwrap().target().unwrap();
|
||||
|
||||
//update repo ref refs/remotes/origin/master to up_target oid
|
||||
ctx.repo().reference(
|
||||
ctx.repository().reference(
|
||||
"refs/remotes/origin/master",
|
||||
coworker_work,
|
||||
true,
|
||||
@ -867,16 +867,16 @@ fn merge_vbranch_upstream_conflict() -> Result<()> {
|
||||
Path::new(&project.path).join(file_path),
|
||||
"line1\nline2\nline3\nline4\n",
|
||||
)?;
|
||||
commit_all(ctx.repo());
|
||||
let target_oid = ctx.repo().head().unwrap().target().unwrap();
|
||||
commit_all(ctx.repository());
|
||||
let target_oid = ctx.repository().head().unwrap().target().unwrap();
|
||||
|
||||
std::fs::write(
|
||||
Path::new(&project.path).join(file_path),
|
||||
"line1\nline2\nline3\nline4\nupstream\n",
|
||||
)?;
|
||||
// add a commit to the target branch it's pointing to so there is something "upstream"
|
||||
commit_all(ctx.repo());
|
||||
let last_push = ctx.repo().head().unwrap().target().unwrap();
|
||||
commit_all(ctx.repository());
|
||||
let last_push = ctx.repository().head().unwrap().target().unwrap();
|
||||
|
||||
// coworker adds some work
|
||||
std::fs::write(
|
||||
@ -884,11 +884,11 @@ fn merge_vbranch_upstream_conflict() -> Result<()> {
|
||||
"line1\nline2\nline3\nline4\nupstream\ncoworker work\n",
|
||||
)?;
|
||||
|
||||
commit_all(ctx.repo());
|
||||
let coworker_work = ctx.repo().head().unwrap().target().unwrap();
|
||||
commit_all(ctx.repository());
|
||||
let coworker_work = ctx.repository().head().unwrap().target().unwrap();
|
||||
|
||||
//update repo ref refs/remotes/origin/master to up_target oid
|
||||
ctx.repo().reference(
|
||||
ctx.repository().reference(
|
||||
"refs/remotes/origin/master",
|
||||
coworker_work,
|
||||
true,
|
||||
@ -980,7 +980,7 @@ fn merge_vbranch_upstream_conflict() -> Result<()> {
|
||||
|
||||
// make sure the last commit was a merge commit (2 parents)
|
||||
let last_id = &branch1.commits[0].id;
|
||||
let last_commit = ctx.repo().find_commit(last_id.to_owned())?;
|
||||
let last_commit = ctx.repository().find_commit(last_id.to_owned())?;
|
||||
assert_eq!(last_commit.parent_count(), 2);
|
||||
|
||||
Ok(())
|
||||
@ -1048,7 +1048,7 @@ fn unapply_branch() -> Result<()> {
|
||||
Path::new(&project.path).join(file_path),
|
||||
"line1\nline2\nline3\nline4\n",
|
||||
)?;
|
||||
commit_all(ctx.repo());
|
||||
commit_all(ctx.repository());
|
||||
|
||||
set_test_target(ctx)?;
|
||||
|
||||
@ -1137,7 +1137,7 @@ fn apply_unapply_added_deleted_files() -> Result<()> {
|
||||
std::fs::write(Path::new(&project.path).join(file_path), "file1\n")?;
|
||||
let file_path2 = Path::new("test2.txt");
|
||||
std::fs::write(Path::new(&project.path).join(file_path2), "file2\n")?;
|
||||
commit_all(ctx.repo());
|
||||
commit_all(ctx.repository());
|
||||
|
||||
set_test_target(ctx)?;
|
||||
|
||||
@ -1227,7 +1227,7 @@ fn detect_mergeable_branch() -> Result<()> {
|
||||
Path::new(&project.path).join(file_path),
|
||||
"line1\nline2\nline3\nline4\n",
|
||||
)?;
|
||||
commit_all(ctx.repo());
|
||||
commit_all(ctx.repository());
|
||||
|
||||
set_test_target(ctx)?;
|
||||
|
||||
@ -1264,8 +1264,8 @@ fn detect_mergeable_branch() -> Result<()> {
|
||||
branch_manager.convert_to_real_branch(branch1_id, guard.write_permission())?;
|
||||
branch_manager.convert_to_real_branch(branch2_id, guard.write_permission())?;
|
||||
|
||||
ctx.repo().set_head("refs/heads/master")?;
|
||||
ctx.repo()
|
||||
ctx.repository().set_head("refs/heads/master")?;
|
||||
ctx.repository()
|
||||
.checkout_head(Some(&mut git2::build::CheckoutBuilder::default().force()))?;
|
||||
|
||||
// create an upstream remote conflicting commit
|
||||
@ -1273,9 +1273,9 @@ fn detect_mergeable_branch() -> Result<()> {
|
||||
Path::new(&project.path).join(file_path),
|
||||
"line1\nline2\nline3\nline4\nupstream\n",
|
||||
)?;
|
||||
commit_all(ctx.repo());
|
||||
let up_target = ctx.repo().head().unwrap().target().unwrap();
|
||||
ctx.repo().reference(
|
||||
commit_all(ctx.repository());
|
||||
let up_target = ctx.repository().head().unwrap().target().unwrap();
|
||||
ctx.repository().reference(
|
||||
"refs/remotes/origin/remote_branch",
|
||||
up_target,
|
||||
true,
|
||||
@ -1289,9 +1289,9 @@ fn detect_mergeable_branch() -> Result<()> {
|
||||
)?;
|
||||
let file_path3 = Path::new("test3.txt");
|
||||
std::fs::write(Path::new(&project.path).join(file_path3), "file3\n")?;
|
||||
commit_all(ctx.repo());
|
||||
let up_target = ctx.repo().head().unwrap().target().unwrap();
|
||||
ctx.repo().reference(
|
||||
commit_all(ctx.repository());
|
||||
let up_target = ctx.repository().head().unwrap().target().unwrap();
|
||||
ctx.repository().reference(
|
||||
"refs/remotes/origin/remote_branch2",
|
||||
up_target,
|
||||
true,
|
||||
@ -1300,8 +1300,9 @@ fn detect_mergeable_branch() -> Result<()> {
|
||||
// remove file_path3
|
||||
std::fs::remove_file(Path::new(&project.path).join(file_path3))?;
|
||||
|
||||
ctx.repo().set_head("refs/heads/gitbutler/integration")?;
|
||||
ctx.repo()
|
||||
ctx.repository()
|
||||
.set_head("refs/heads/gitbutler/integration")?;
|
||||
ctx.repository()
|
||||
.checkout_head(Some(&mut git2::build::CheckoutBuilder::default().force()))?;
|
||||
|
||||
// create branches that conflict with our earlier branches
|
||||
@ -1376,16 +1377,16 @@ fn upstream_integrated_vbranch() -> Result<()> {
|
||||
|
||||
let vb_state = VirtualBranchesHandle::new(project.gb_dir());
|
||||
|
||||
let base_commit = ctx.repo().head().unwrap().target().unwrap();
|
||||
let base_commit = ctx.repository().head().unwrap().target().unwrap();
|
||||
|
||||
std::fs::write(
|
||||
Path::new(&project.path).join("test.txt"),
|
||||
"file1\nversion2\n",
|
||||
)?;
|
||||
commit_all(ctx.repo());
|
||||
commit_all(ctx.repository());
|
||||
|
||||
let upstream_commit = ctx.repo().head().unwrap().target().unwrap();
|
||||
ctx.repo().reference(
|
||||
let upstream_commit = ctx.repository().head().unwrap().target().unwrap();
|
||||
ctx.repository().reference(
|
||||
"refs/remotes/origin/master",
|
||||
upstream_commit,
|
||||
true,
|
||||
@ -1398,7 +1399,8 @@ fn upstream_integrated_vbranch() -> Result<()> {
|
||||
sha: base_commit,
|
||||
push_remote_name: None,
|
||||
})?;
|
||||
ctx.repo().remote("origin", "http://origin.com/project")?;
|
||||
ctx.repository()
|
||||
.remote("origin", "http://origin.com/project")?;
|
||||
update_gitbutler_integration(&vb_state, ctx)?;
|
||||
|
||||
// create vbranches, one integrated, one not
|
||||
@ -1725,8 +1727,8 @@ fn commit_partial_by_file() -> Result<()> {
|
||||
(PathBuf::from("test2.txt"), "file2\n"),
|
||||
]));
|
||||
|
||||
let commit1_oid = ctx.repo().head().unwrap().target().unwrap();
|
||||
let commit1 = ctx.repo().find_commit(commit1_oid).unwrap();
|
||||
let commit1_oid = ctx.repository().head().unwrap().target().unwrap();
|
||||
let commit1 = ctx.repository().find_commit(commit1_oid).unwrap();
|
||||
|
||||
set_test_target(ctx)?;
|
||||
|
||||
@ -1752,17 +1754,17 @@ fn commit_partial_by_file() -> Result<()> {
|
||||
// branch one test.txt has just the 1st and 3rd hunks applied
|
||||
let commit2 = &branch1.commits[0].id;
|
||||
let commit2 = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit2.to_owned())
|
||||
.expect("failed to get commit object");
|
||||
|
||||
let tree = commit1.tree().expect("failed to get tree");
|
||||
let file_list = tree_to_file_list(ctx.repo(), &tree);
|
||||
let file_list = tree_to_file_list(ctx.repository(), &tree);
|
||||
assert_eq!(file_list, vec!["test.txt", "test2.txt"]);
|
||||
|
||||
// get the tree
|
||||
let tree = commit2.tree().expect("failed to get tree");
|
||||
let file_list = tree_to_file_list(ctx.repo(), &tree);
|
||||
let file_list = tree_to_file_list(ctx.repository(), &tree);
|
||||
assert_eq!(file_list, vec!["test.txt", "test3.txt"]);
|
||||
|
||||
Ok(())
|
||||
@ -1776,8 +1778,8 @@ fn commit_add_and_delete_files() -> Result<()> {
|
||||
(PathBuf::from("test2.txt"), "file2\n"),
|
||||
]));
|
||||
|
||||
let commit1_oid = ctx.repo().head().unwrap().target().unwrap();
|
||||
let commit1 = ctx.repo().find_commit(commit1_oid).unwrap();
|
||||
let commit1_oid = ctx.repository().head().unwrap().target().unwrap();
|
||||
let commit1 = ctx.repository().find_commit(commit1_oid).unwrap();
|
||||
|
||||
set_test_target(ctx)?;
|
||||
|
||||
@ -1803,17 +1805,17 @@ fn commit_add_and_delete_files() -> Result<()> {
|
||||
// branch one test.txt has just the 1st and 3rd hunks applied
|
||||
let commit2 = &branch1.commits[0].id;
|
||||
let commit2 = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit2.to_owned())
|
||||
.expect("failed to get commit object");
|
||||
|
||||
let tree = commit1.tree().expect("failed to get tree");
|
||||
let file_list = tree_to_file_list(ctx.repo(), &tree);
|
||||
let file_list = tree_to_file_list(ctx.repository(), &tree);
|
||||
assert_eq!(file_list, vec!["test.txt", "test2.txt"]);
|
||||
|
||||
// get the tree
|
||||
let tree = commit2.tree().expect("failed to get tree");
|
||||
let file_list = tree_to_file_list(ctx.repo(), &tree);
|
||||
let file_list = tree_to_file_list(ctx.repository(), &tree);
|
||||
assert_eq!(file_list, vec!["test.txt", "test3.txt"]);
|
||||
|
||||
Ok(())
|
||||
@ -1859,13 +1861,13 @@ fn commit_executable_and_symlinks() -> Result<()> {
|
||||
|
||||
let commit = &branch1.commits[0].id;
|
||||
let commit = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(commit.to_owned())
|
||||
.expect("failed to get commit object");
|
||||
|
||||
let tree = commit.tree().expect("failed to get tree");
|
||||
|
||||
let list = tree_to_entry_list(ctx.repo(), &tree);
|
||||
let list = tree_to_entry_list(ctx.repository(), &tree);
|
||||
assert_eq!(list[0].0, "test.txt");
|
||||
assert_eq!(list[0].1, "100644");
|
||||
assert_eq!(list[1].0, "test2.txt");
|
||||
@ -1942,9 +1944,9 @@ fn verify_branch_commits_to_integration() -> Result<()> {
|
||||
// write two commits
|
||||
let file_path2 = Path::new("test2.txt");
|
||||
std::fs::write(Path::new(&project.path).join(file_path2), "file")?;
|
||||
commit_all(ctx.repo());
|
||||
commit_all(ctx.repository());
|
||||
std::fs::write(Path::new(&project.path).join(file_path2), "update")?;
|
||||
commit_all(ctx.repo());
|
||||
commit_all(ctx.repository());
|
||||
|
||||
// verify puts commits onto the virtual branch
|
||||
verify_branch(ctx, guard.write_permission()).unwrap();
|
||||
@ -1970,7 +1972,7 @@ fn verify_branch_not_integration() -> Result<()> {
|
||||
let mut guard = project.exclusive_worktree_access();
|
||||
verify_branch(ctx, guard.write_permission()).unwrap();
|
||||
|
||||
ctx.repo().set_head("refs/heads/master")?;
|
||||
ctx.repository().set_head("refs/heads/master")?;
|
||||
|
||||
let verify_result = verify_branch(ctx, guard.write_permission());
|
||||
assert!(verify_result.is_err());
|
||||
@ -2009,7 +2011,7 @@ fn pre_commit_hook_rejection() -> Result<()> {
|
||||
exit 1
|
||||
";
|
||||
|
||||
git2_hooks::create_hook(ctx.repo(), git2_hooks::HOOK_PRE_COMMIT, hook);
|
||||
git2_hooks::create_hook(ctx.repository(), git2_hooks::HOOK_PRE_COMMIT, hook);
|
||||
|
||||
let res = commit(ctx, branch1_id, "test commit", None, true);
|
||||
|
||||
@ -2048,9 +2050,9 @@ fn post_commit_hook() -> Result<()> {
|
||||
touch hook_ran
|
||||
";
|
||||
|
||||
git2_hooks::create_hook(ctx.repo(), git2_hooks::HOOK_POST_COMMIT, hook);
|
||||
git2_hooks::create_hook(ctx.repository(), git2_hooks::HOOK_POST_COMMIT, hook);
|
||||
|
||||
let hook_ran_proof = ctx.repo().path().parent().unwrap().join("hook_ran");
|
||||
let hook_ran_proof = ctx.repository().path().parent().unwrap().join("hook_ran");
|
||||
|
||||
assert!(!hook_ran_proof.exists());
|
||||
|
||||
@ -2088,7 +2090,7 @@ fn commit_msg_hook_rejection() -> Result<()> {
|
||||
exit 1
|
||||
";
|
||||
|
||||
git2_hooks::create_hook(ctx.repo(), git2_hooks::HOOK_COMMIT_MSG, hook);
|
||||
git2_hooks::create_hook(ctx.repository(), git2_hooks::HOOK_COMMIT_MSG, hook);
|
||||
|
||||
let res = commit(ctx, branch1_id, "test commit", None, true);
|
||||
|
||||
|
@ -67,7 +67,7 @@ impl CommandContext {
|
||||
&self.project
|
||||
}
|
||||
|
||||
pub fn repo(&self) -> &git2::Repository {
|
||||
pub fn repository(&self) -> &git2::Repository {
|
||||
&self.git_repository
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ where
|
||||
T: Into<GitHunk> + Clone,
|
||||
{
|
||||
// read the base sha into an index
|
||||
let git_repository: &git2::Repository = ctx.repo();
|
||||
let git_repository: &git2::Repository = ctx.repository();
|
||||
|
||||
let head_commit = git_repository.find_commit(commit_oid)?;
|
||||
let base_tree = head_commit.tree()?;
|
||||
@ -49,7 +49,7 @@ pub fn hunks_onto_tree<T>(
|
||||
where
|
||||
T: Into<GitHunk> + Clone,
|
||||
{
|
||||
let git_repository = ctx.repo();
|
||||
let git_repository = ctx.repository();
|
||||
let mut builder = git2::build::TreeUpdateBuilder::new();
|
||||
// now update the index with content in the working directory for each file
|
||||
for (rel_path, hunks) in files {
|
||||
@ -193,7 +193,7 @@ where
|
||||
|
||||
// now write out the tree
|
||||
let tree_oid = builder
|
||||
.create_updated(ctx.repo(), base_tree)
|
||||
.create_updated(ctx.repository(), base_tree)
|
||||
.context("failed to write updated tree")?;
|
||||
|
||||
Ok(tree_oid)
|
||||
|
@ -16,19 +16,19 @@ pub trait RepoCommands {
|
||||
impl RepoCommands for Project {
|
||||
fn get_local_config(&self, key: &str) -> Result<Option<String>> {
|
||||
let project_repo = CommandContext::open(self)?;
|
||||
let config: Config = project_repo.repo().into();
|
||||
let config: Config = project_repo.repository().into();
|
||||
config.get_local(key)
|
||||
}
|
||||
|
||||
fn set_local_config(&self, key: &str, value: &str) -> Result<()> {
|
||||
let project_repo = CommandContext::open(self)?;
|
||||
let config: Config = project_repo.repo().into();
|
||||
let config: Config = project_repo.repository().into();
|
||||
config.set_local(key, value)
|
||||
}
|
||||
|
||||
fn check_signing_settings(&self) -> Result<bool> {
|
||||
let repo = CommandContext::open(self)?;
|
||||
let signed = repo.repo().sign_buffer(&BString::new("test".into()).into());
|
||||
let signed = repo.repository().sign_buffer(&BString::new("test".into()).into());
|
||||
match signed {
|
||||
Ok(_) => Ok(true),
|
||||
Err(e) => Err(e),
|
||||
@ -37,12 +37,12 @@ impl RepoCommands for Project {
|
||||
|
||||
fn remotes(&self) -> Result<Vec<String>> {
|
||||
let ctx = CommandContext::open(self)?;
|
||||
ctx.repo().remotes_as_string()
|
||||
ctx.repository().remotes_as_string()
|
||||
}
|
||||
|
||||
fn add_remote(&self, name: &str, url: &str) -> Result<()> {
|
||||
let ctx = CommandContext::open(self)?;
|
||||
ctx.repo().remote(name, url)?;
|
||||
ctx.repository().remote(name, url)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ impl Helper {
|
||||
ctx: &'a CommandContext,
|
||||
remote_name: &str,
|
||||
) -> Result<Vec<(git2::Remote, Vec<Credential>)>, HelpError> {
|
||||
let remote = ctx.repo().find_remote(remote_name)?;
|
||||
let remote = ctx.repository().find_remote(remote_name)?;
|
||||
let remote_url = Url::from_str(remote.url().ok_or(HelpError::NoUrlSet)?)
|
||||
.context("failed to parse remote url")?;
|
||||
|
||||
@ -99,7 +99,7 @@ impl Helper {
|
||||
Ok(remote)
|
||||
} else {
|
||||
let ssh_url = remote_url.as_ssh()?;
|
||||
ctx.repo().remote_anonymous(&ssh_url.to_string())
|
||||
ctx.repository().remote_anonymous(&ssh_url.to_string())
|
||||
}?;
|
||||
|
||||
Ok(vec![(
|
||||
@ -115,7 +115,7 @@ impl Helper {
|
||||
Ok(remote)
|
||||
} else {
|
||||
let url = remote_url.as_https()?;
|
||||
ctx.repo().remote_anonymous(&url.to_string())
|
||||
ctx.repository().remote_anonymous(&url.to_string())
|
||||
}?;
|
||||
let flow = Self::https_flow(ctx, &remote_url)?
|
||||
.into_iter()
|
||||
@ -137,7 +137,7 @@ impl Helper {
|
||||
let mut flow = vec![];
|
||||
|
||||
let mut helper = git2::CredentialHelper::new(&remote_url.to_string());
|
||||
let config = ctx.repo().config()?;
|
||||
let config = ctx.repository().config()?;
|
||||
helper.config(&config);
|
||||
if let Some((username, password)) = helper.execute() {
|
||||
flow.push(HttpsCredential::CredentialHelper { username, password });
|
||||
|
@ -40,21 +40,21 @@ pub fn cherry_rebase_group(
|
||||
// now, rebase unchanged commits onto the new commit
|
||||
let commits_to_rebase = ids_to_rebase
|
||||
.iter()
|
||||
.map(|oid| ctx.repo().find_commit(oid.to_owned()))
|
||||
.map(|oid| ctx.repository().find_commit(oid.to_owned()))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.context("failed to read commits to rebase")?;
|
||||
|
||||
let new_head_id = commits_to_rebase
|
||||
.into_iter()
|
||||
.fold(
|
||||
ctx.repo()
|
||||
ctx.repository()
|
||||
.find_commit(target_commit_oid)
|
||||
.context("failed to find new commit"),
|
||||
|head, to_rebase| {
|
||||
let head = head?;
|
||||
|
||||
let mut cherrypick_index = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.cherrypick_commit(&to_rebase, &head, 0, None)
|
||||
.context("failed to cherry pick")?;
|
||||
|
||||
@ -63,18 +63,18 @@ pub fn cherry_rebase_group(
|
||||
}
|
||||
|
||||
let merge_tree_oid = cherrypick_index
|
||||
.write_tree_to(ctx.repo())
|
||||
.write_tree_to(ctx.repository())
|
||||
.context("failed to write merge tree")?;
|
||||
|
||||
let merge_tree = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.find_tree(merge_tree_oid)
|
||||
.context("failed to find merge tree")?;
|
||||
|
||||
let commit_headers = to_rebase.gitbutler_headers();
|
||||
|
||||
let commit_oid = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.commit_with_signature(
|
||||
None,
|
||||
&to_rebase.author(),
|
||||
@ -86,7 +86,7 @@ pub fn cherry_rebase_group(
|
||||
)
|
||||
.context("failed to create commit")?;
|
||||
|
||||
ctx.repo()
|
||||
ctx.repository()
|
||||
.find_commit(commit_oid)
|
||||
.context("failed to find commit")
|
||||
},
|
||||
|
@ -60,7 +60,7 @@ impl RepoActionsExt for CommandContext {
|
||||
let target_branch_refname =
|
||||
Refname::from_str(&format!("refs/remotes/{}/{}", remote_name, branch_name))?;
|
||||
let branch = self
|
||||
.repo()
|
||||
.repository()
|
||||
.find_branch_by_refname(&target_branch_refname)?
|
||||
.ok_or(anyhow!("failed to find branch {}", target_branch_refname))?;
|
||||
|
||||
@ -95,7 +95,7 @@ impl RepoActionsExt for CommandContext {
|
||||
|
||||
fn add_branch_reference(&self, branch: &Branch) -> Result<()> {
|
||||
let (should_write, with_force) =
|
||||
match self.repo().find_reference(&branch.refname().to_string()) {
|
||||
match self.repository().find_reference(&branch.refname().to_string()) {
|
||||
Ok(reference) => match reference.target() {
|
||||
Some(head_oid) => Ok((head_oid != branch.head, true)),
|
||||
None => Ok((true, true)),
|
||||
@ -108,7 +108,7 @@ impl RepoActionsExt for CommandContext {
|
||||
.context("failed to lookup reference")?;
|
||||
|
||||
if should_write {
|
||||
self.repo()
|
||||
self.repository()
|
||||
.reference(
|
||||
&branch.refname().to_string(),
|
||||
branch.head,
|
||||
@ -122,7 +122,7 @@ impl RepoActionsExt for CommandContext {
|
||||
}
|
||||
|
||||
fn delete_branch_reference(&self, branch: &Branch) -> Result<()> {
|
||||
match self.repo().find_reference(&branch.refname().to_string()) {
|
||||
match self.repository().find_reference(&branch.refname().to_string()) {
|
||||
Ok(mut reference) => {
|
||||
reference
|
||||
.delete()
|
||||
@ -141,7 +141,7 @@ impl RepoActionsExt for CommandContext {
|
||||
fn l(&self, from: git2::Oid, to: LogUntil) -> Result<Vec<git2::Oid>> {
|
||||
match to {
|
||||
LogUntil::Commit(oid) => {
|
||||
let mut revwalk = self.repo().revwalk().context("failed to create revwalk")?;
|
||||
let mut revwalk = self.repository().revwalk().context("failed to create revwalk")?;
|
||||
revwalk
|
||||
.push(from)
|
||||
.context(format!("failed to push {}", from))?;
|
||||
@ -153,7 +153,7 @@ impl RepoActionsExt for CommandContext {
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
}
|
||||
LogUntil::Take(n) => {
|
||||
let mut revwalk = self.repo().revwalk().context("failed to create revwalk")?;
|
||||
let mut revwalk = self.repository().revwalk().context("failed to create revwalk")?;
|
||||
revwalk
|
||||
.push(from)
|
||||
.context(format!("failed to push {}", from))?;
|
||||
@ -163,7 +163,7 @@ impl RepoActionsExt for CommandContext {
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
}
|
||||
LogUntil::When(cond) => {
|
||||
let mut revwalk = self.repo().revwalk().context("failed to create revwalk")?;
|
||||
let mut revwalk = self.repository().revwalk().context("failed to create revwalk")?;
|
||||
revwalk
|
||||
.push(from)
|
||||
.context(format!("failed to push {}", from))?;
|
||||
@ -173,7 +173,7 @@ impl RepoActionsExt for CommandContext {
|
||||
oids.push(oid);
|
||||
|
||||
let commit = self
|
||||
.repo()
|
||||
.repository()
|
||||
.find_commit(oid)
|
||||
.context("failed to find commit")?;
|
||||
|
||||
@ -184,7 +184,7 @@ impl RepoActionsExt for CommandContext {
|
||||
Ok(oids)
|
||||
}
|
||||
LogUntil::End => {
|
||||
let mut revwalk = self.repo().revwalk().context("failed to create revwalk")?;
|
||||
let mut revwalk = self.repository().revwalk().context("failed to create revwalk")?;
|
||||
revwalk
|
||||
.push(from)
|
||||
.context(format!("failed to push {}", from))?;
|
||||
@ -205,7 +205,7 @@ impl RepoActionsExt for CommandContext {
|
||||
Ok(self
|
||||
.list(from, to)?
|
||||
.into_iter()
|
||||
.map(|oid| self.repo().find_commit(oid))
|
||||
.map(|oid| self.repository().find_commit(oid))
|
||||
.collect::<Result<Vec<_>, _>>()?)
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ impl RepoActionsExt for CommandContext {
|
||||
fn log(&self, from: git2::Oid, to: LogUntil) -> Result<Vec<git2::Commit>> {
|
||||
self.l(from, to)?
|
||||
.into_iter()
|
||||
.map(|oid| self.repo().find_commit(oid))
|
||||
.map(|oid| self.repository().find_commit(oid))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.context("failed to collect commits")
|
||||
}
|
||||
@ -232,7 +232,7 @@ impl RepoActionsExt for CommandContext {
|
||||
commit_headers: Option<CommitHeadersV2>,
|
||||
) -> Result<git2::Oid> {
|
||||
let (author, committer) = self.signatures().context("failed to get signatures")?;
|
||||
self.repo()
|
||||
self.repository()
|
||||
.commit_with_signature(
|
||||
None,
|
||||
&author,
|
||||
@ -428,7 +428,7 @@ impl RepoActionsExt for CommandContext {
|
||||
}
|
||||
|
||||
fn signatures(&self) -> Result<(git2::Signature, git2::Signature)> {
|
||||
let repo = gix::open(self.repo().path())?;
|
||||
let repo = gix::open(self.repository().path())?;
|
||||
|
||||
let default_actor = gix::actor::SignatureRef {
|
||||
name: GITBUTLER_INTEGRATION_COMMIT_AUTHOR_NAME.into(),
|
||||
@ -436,7 +436,7 @@ impl RepoActionsExt for CommandContext {
|
||||
time: Default::default(),
|
||||
};
|
||||
let author = repo.author().transpose()?.unwrap_or(default_actor);
|
||||
let config: Config = self.repo().into();
|
||||
let config: Config = self.repository().into();
|
||||
let committer = if config.user_real_comitter()? {
|
||||
repo.committer().transpose()?.unwrap_or(default_actor)
|
||||
} else {
|
||||
|
@ -68,7 +68,7 @@ fn push_target(
|
||||
batch_size: usize,
|
||||
) -> Result<()> {
|
||||
let ids = batch_rev_walk(
|
||||
ctx.repo(),
|
||||
ctx.repository(),
|
||||
batch_size,
|
||||
default_target.sha,
|
||||
gb_code_last_commit,
|
||||
@ -139,7 +139,7 @@ fn batch_rev_walk(
|
||||
|
||||
fn collect_refs(ctx: &CommandContext) -> anyhow::Result<Vec<Refname>> {
|
||||
Ok(ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.references_glob("refs/*")?
|
||||
.flatten()
|
||||
.filter_map(|r| {
|
||||
@ -243,7 +243,7 @@ fn push_to_gitbutler_server(
|
||||
let headers = &[auth_header.as_str()];
|
||||
push_options.custom_headers(headers);
|
||||
|
||||
let mut remote = project_repo.repo().remote_anonymous(&url.to_string())?;
|
||||
let mut remote = project_repo.repository().remote_anonymous(&url.to_string())?;
|
||||
|
||||
remote
|
||||
.push(ref_specs, Some(&mut push_options))
|
||||
|
@ -37,7 +37,7 @@ impl App {
|
||||
pub fn git_remote_branches(&self, project_id: ProjectId) -> Result<Vec<RemoteRefname>> {
|
||||
let project = self.projects().get(project_id)?;
|
||||
let ctx = CommandContext::open(&project)?;
|
||||
ctx.repo().remote_branches()
|
||||
ctx.repository().remote_branches()
|
||||
}
|
||||
|
||||
pub fn git_test_push(
|
||||
@ -69,7 +69,7 @@ impl App {
|
||||
let project = self.projects().get(project_id)?;
|
||||
let ctx = CommandContext::open(&project)?;
|
||||
let size = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.index()
|
||||
.context("failed to get index size")?
|
||||
.len();
|
||||
@ -79,7 +79,7 @@ impl App {
|
||||
pub fn git_head(&self, project_id: ProjectId) -> Result<String> {
|
||||
let project = self.projects().get(project_id)?;
|
||||
let ctx = CommandContext::open(&project)?;
|
||||
let head = ctx.repo().head().context("failed to get repository head")?;
|
||||
let head = ctx.repository().head().context("failed to get repository head")?;
|
||||
Ok(head.name().unwrap().to_string())
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ pub mod virtual_branches {
|
||||
let vb_state = VirtualBranchesHandle::new(ctx.project().gb_dir());
|
||||
let (remote_repo, _tmp) = empty_bare_repository();
|
||||
let mut remote = ctx
|
||||
.repo()
|
||||
.repository()
|
||||
.remote("origin", remote_repo.path().to_str().unwrap())
|
||||
.expect("failed to add remote");
|
||||
remote.push(&["refs/heads/master:refs/heads/master"], None)?;
|
||||
|
@ -153,10 +153,10 @@ impl Handler {
|
||||
}
|
||||
"HEAD" => {
|
||||
let ctx = open_projects_repository()?;
|
||||
let head_ref = ctx.repo().head().context("failed to get head")?;
|
||||
let head_ref = ctx.repository().head().context("failed to get head")?;
|
||||
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 = ctx.repo().find_reference(
|
||||
let mut integration_reference = ctx.repository().find_reference(
|
||||
&Refname::from(LocalRefname::new("gitbutler/integration", None))
|
||||
.to_string(),
|
||||
)?;
|
||||
|
Loading…
Reference in New Issue
Block a user