Skip to content

Commit 68c4c76

Browse files
commit message wip
1 parent 9030efc commit 68c4c76

2 files changed

Lines changed: 31 additions & 15 deletions

File tree

crates/gitbutler-edit-mode/src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,22 @@ fn find_or_create_base_commit(
9696

9797
let base_tree = repo.find_real_tree(&commit, ConflictedTreeKey::Ours)?;
9898

99+
let concrete_commit = gix::objs::Commit::try_from(commit.decode()?)?;
100+
let extra_headers: Vec<(BString, BString)> = Headers::try_from_commit(&concrete_commit)
101+
.map(|commit_headers| {
102+
let headers = Headers {
103+
conflicted: None,
104+
..commit_headers
105+
};
106+
(&headers).into()
107+
})
108+
.unwrap_or_default();
109+
let message = but_core::commit::strip_conflict_markers(concrete_commit.message.as_ref());
99110
let commit = gix::objs::Commit {
100111
tree: base_tree.into(),
101-
extra_headers: Vec::new(),
102-
..gix::objs::Commit::try_from(commit.decode()?)?
112+
extra_headers,
113+
message,
114+
..concrete_commit
103115
};
104116
Ok(repo.write_object(&commit)?.detach())
105117
}
@@ -271,22 +283,11 @@ pub(crate) fn save_and_return_to_workspace(ctx: &Context, perm: &mut RepoExclusi
271283
let new_commit_oid = if decoded_head_commit.tree() == tree_id {
272284
head_commit.id
273285
} else {
274-
let mut commit = gix::objs::Commit::try_from(decoded_head_commit.clone())?;
275-
let extra_headers: Vec<(BString, BString)> = Headers::try_from_commit(&commit)
276-
.map(|commit_headers| {
277-
let headers = Headers {
278-
conflicted: None,
279-
..commit_headers
280-
};
281-
(&headers).into()
282-
})
283-
.unwrap_or_default();
284-
commit.message = but_core::commit::strip_conflict_markers(commit.message.as_ref());
286+
let commit = gix::objs::Commit::try_from(decoded_head_commit.clone())?;
285287
but_rebase::commit::create(
286288
repo,
287289
gix::objs::Commit {
288290
tree: tree_id,
289-
extra_headers,
290291
..commit
291292
},
292293
but_rebase::commit::DateMode::CommitterUpdateAuthorKeep,

crates/gitbutler-edit-mode/tests/edit_mode.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,22 @@ fn enter_edit_mode_checks_out_conflicted_commit() -> Result<()> {
362362
);
363363
insta::assert_debug_snapshot!(
364364
repo.head_commit()?.message()?.summary(),
365-
@r#""[conflict] Changes to make millions""#
365+
@r#""Changes to make millions""#
366+
);
367+
insta::assert_debug_snapshot!(
368+
repo.head_commit()?.decode()?.extra_headers,
369+
@r#"
370+
[
371+
(
372+
"gitbutler-headers-version",
373+
"2",
374+
),
375+
(
376+
"change-id",
377+
"00000000-0000-0000-0000-000000000001",
378+
),
379+
]
380+
"#
366381
);
367382

368383
insta::assert_snapshot!(

0 commit comments

Comments
 (0)