git: Fill the commit message buffer from MERGE_MSG (#24843)

This PR uses the template merge message in `.git/MERGE_MSG` to populate
the commit message buffer in the git panel. This is done:

- when the commit message buffer is first created
- when the list of merge heads in .git changes, only if the buffer
doesn't already have some text in it

Hopefully this strikes a good balance between convenience and not
stomping on the user's toes.

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-02-15 13:29:45 -05:00 committed by GitHub
parent 394bb8f4e6
commit 4ff1173047
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 12 deletions

View file

@ -576,6 +576,7 @@ pub struct LocalRepositoryEntry {
/// Absolute path to the .git file, if we're in a git worktree.
pub(crate) dot_git_worktree_abs_path: Option<Arc<Path>>,
pub current_merge_head_shas: Vec<String>,
pub merge_message: Option<String>,
}
impl sum_tree::Item for LocalRepositoryEntry {
@ -3524,6 +3525,7 @@ impl BackgroundScannerState {
dot_git_dir_abs_path: actual_dot_git_dir_abs_path.into(),
dot_git_worktree_abs_path,
current_merge_head_shas: Default::default(),
merge_message: None,
};
self.snapshot
@ -5491,6 +5493,10 @@ impl BackgroundScanner {
&local_repository.work_directory_id,
|entry| {
entry.current_merge_head_shas = merge_head_shas;
entry.merge_message = std::fs::read_to_string(
local_repository.dot_git_dir_abs_path.join("MERGE_MSG"),
)
.ok();
entry.status_scan_id += 1;
},
);