Skip to content

Commit

Permalink
Merge pull request #4463 from gitbutlerapp/get-workspace-head-return-…
Browse files Browse the repository at this point in the history
…early-when-nothign-applied

get_workspace_head exit early when there are no applied branches
  • Loading branch information
krlvi authored Jul 22, 2024
2 parents 67c2ee7 + d8a1b4b commit 0787212
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions crates/gitbutler-branch-actions/src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ pub(crate) fn get_workspace_head(project_repo: &ProjectRepository) -> Result<git

let mut virtual_branches: Vec<Branch> = vb_state.list_branches_in_workspace()?;

let branch_heads = virtual_branches
.iter()
.map(|b| repo.find_commit(b.head))
.collect::<Result<Vec<_>, _>>()?;
let branch_head_refs = branch_heads.iter().collect::<Vec<_>>();

let target_commit = repo.find_commit(target.sha)?;
let mut workspace_tree = target_commit.tree()?;

// If no branches are applied then the workspace head is the target.
if branch_head_refs.is_empty() {
return Ok(target_commit.id());
}

if conflicts::is_conflicting(project_repo, None)? {
let merge_parent =
conflicts::merge_parent(project_repo)?.ok_or(anyhow!("No merge parent"))?;
Expand All @@ -68,17 +79,6 @@ pub(crate) fn get_workspace_head(project_repo: &ProjectRepository) -> Result<git
}
}

let branch_heads = virtual_branches
.iter()
.map(|b| repo.find_commit(b.head))
.collect::<Result<Vec<_>, _>>()?;
let branch_head_refs = branch_heads.iter().collect::<Vec<_>>();

// If no branches are applied then the workspace head is the target.
if branch_head_refs.is_empty() {
return Ok(target_commit.id());
}

// TODO(mg): Can we make this a constant?
let committer = get_integration_commiter()?;

Expand Down

0 comments on commit 0787212

Please sign in to comment.