Skip to content

Commit 3099e75

Browse files
authored
Merge branch 'master' into fix/create-pr-from-fork
2 parents 99198b8 + 336c0fb commit 3099e75

File tree

3 files changed

+51
-39
lines changed

3 files changed

+51
-39
lines changed

apps/desktop/src/components/v3/CommitView.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
? stackService.upstreamCommitById(projectId, commitKey)
5353
: stackService.commitById(projectId, commitKey)
5454
);
55-
const isUnapplied = false; // TODO
56-
const branchRefName = undefined; // TODO
5755
5856
const changesResult = $derived(stackService.commitChanges(projectId, commitKey.commitId));
5957
@@ -118,14 +116,11 @@
118116
}
119117
120118
function canEdit() {
121-
if (isUnapplied) return false;
122-
if (!modeService) return false;
123-
124-
return true;
119+
return modeService !== undefined;
125120
}
126121
127122
async function editPatch() {
128-
if (!canEdit() || !branchRefName) return;
123+
if (!canEdit()) return;
129124
await modeService!.enterEditMode(commitKey.commitId, stackId);
130125
}
131126
</script>

crates/gitbutler-branch-actions/src/integration.rs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -246,40 +246,42 @@ pub fn update_workspace_commit(
246246
index.read_tree(&workspace_tree)?;
247247
index.write()?;
248248

249-
// finally, update the refs/gitbutler/ heads to the states of the current virtual branches
250-
for branch in &virtual_branches {
251-
let wip_tree = repo.find_tree(branch.tree(ctx)?)?;
252-
let mut branch_head = repo.find_commit(branch.head_oid(&gix_repo)?.to_git2())?;
253-
let head_tree = branch_head.tree()?;
254-
255-
// create a wip commit if there is wip
256-
if head_tree.id() != wip_tree.id() {
257-
let mut message = "GitButler WIP Commit".to_string();
258-
message.push_str("\n\n");
259-
message.push_str("This is a WIP commit for the virtual branch '");
260-
message.push_str(branch.name.as_str());
261-
message.push_str("'\n\n");
262-
message.push_str("This commit is used to store the state of the virtual branch\n");
263-
message.push_str("while you are working on it. It is not meant to be used for\n");
264-
message.push_str("anything else.\n\n");
265-
let branch_head_oid = repo.commit(
266-
None,
267-
&committer,
268-
&committer,
269-
&message,
270-
&wip_tree,
271-
&[&branch_head],
272-
// None,
249+
if !ctx.app_settings().feature_flags.v3 {
250+
// finally, update the refs/gitbutler/ heads to the states of the current virtual branches
251+
for branch in &virtual_branches {
252+
let wip_tree = repo.find_tree(branch.tree(ctx)?)?;
253+
let mut branch_head = repo.find_commit(branch.head_oid(&gix_repo)?.to_git2())?;
254+
let head_tree = branch_head.tree()?;
255+
256+
// create a wip commit if there is wip
257+
if head_tree.id() != wip_tree.id() {
258+
let mut message = "GitButler WIP Commit".to_string();
259+
message.push_str("\n\n");
260+
message.push_str("This is a WIP commit for the virtual branch '");
261+
message.push_str(branch.name.as_str());
262+
message.push_str("'\n\n");
263+
message.push_str("This commit is used to store the state of the virtual branch\n");
264+
message.push_str("while you are working on it. It is not meant to be used for\n");
265+
message.push_str("anything else.\n\n");
266+
let branch_head_oid = repo.commit(
267+
None,
268+
&committer,
269+
&committer,
270+
&message,
271+
&wip_tree,
272+
&[&branch_head],
273+
// None,
274+
)?;
275+
branch_head = repo.find_commit(branch_head_oid)?;
276+
}
277+
278+
repo.reference(
279+
&branch.refname()?.to_string(),
280+
branch_head.id(),
281+
true,
282+
"update virtual branch",
273283
)?;
274-
branch_head = repo.find_commit(branch_head_oid)?;
275284
}
276-
277-
repo.reference(
278-
&branch.refname()?.to_string(),
279-
branch_head.id(),
280-
true,
281-
"update virtual branch",
282-
)?;
283285
}
284286

285287
Ok(final_commit)

crates/gitbutler-branch-actions/src/upstream_integration.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,19 @@ pub fn upstream_integration_statuses(
406406
let (merge_options_fail_fast, _conflict_kind) =
407407
gix_repo.merge_options_no_rewrites_fail_fast()?;
408408

409+
let merge_outcome = gix_repo.merge_trees(
410+
merge_base_tree,
411+
gix_repo.head()?.peel_to_commit_in_place()?.tree_id()?,
412+
target_tree,
413+
gix_repo.default_merge_labels(),
414+
merge_options_fail_fast.clone(),
415+
)?;
416+
let committed_conflicts = merge_outcome
417+
.conflicts
418+
.iter()
419+
.filter(|c| c.is_unresolved(TreatAsUnresolved::git()))
420+
.collect::<Vec<_>>();
421+
409422
let worktree_conflicts = gix_repo
410423
.merge_trees(
411424
merge_base_tree,
@@ -417,6 +430,8 @@ pub fn upstream_integration_statuses(
417430
.conflicts
418431
.iter()
419432
.filter(|c| c.is_unresolved(TreatAsUnresolved::git()))
433+
// only include conflicts that are not in the list committed_conflicts
434+
.filter(|c| !committed_conflicts.iter().any(|cc| cc.ours == c.ours))
420435
.map(|c| c.ours.location().into())
421436
.collect::<Vec<BStringForFrontend>>();
422437

0 commit comments

Comments
 (0)