Skip to content

Commit 48f9331

Browse files
authored
Use git_message_prettify (#924)
1 parent 5f34e9c commit 48f9331

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
## Fixed
1414
- appropriate error message when pulling deleted remote branch ([#911](https://github.com/extrawurst/gitui/issues/991))
1515
- improved color contrast in branches popup for light themes [[@Cottser](https://github.com/Cottser)] ([#922](https://github.com/extrawurst/gitui/issues/922))
16+
- use git_message_prettify for commit messages ([#917](https://github.com/extrawurst/gitui/issues/917))
1617

1718
## [0.17.1] - 2021-09-10
1819

asyncgit/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub use crate::{
5757
},
5858
tags::AsyncTags,
5959
};
60+
pub use git2::message_prettify;
6061
use std::{
6162
collections::hash_map::DefaultHasher,
6263
hash::{Hash, Hasher},

src/components/commit.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
};
1212
use anyhow::Result;
1313
use asyncgit::{
14-
cached,
14+
cached, message_prettify,
1515
sync::{
1616
self, get_config_string, CommitId, HookResult, RepoState,
1717
},
@@ -149,19 +149,7 @@ impl CommitComponent {
149149
drop(file);
150150
std::fs::remove_file(&file_path)?;
151151

152-
let message: String = message
153-
.lines()
154-
.flat_map(|l| {
155-
if l.starts_with('#') {
156-
vec![]
157-
} else {
158-
vec![l, "\n"]
159-
}
160-
})
161-
.collect();
162-
163-
let message = message.trim().to_string();
164-
152+
message = message_prettify(message, Some(b'#'))?;
165153
self.input.set_text(message);
166154
self.input.show()?;
167155

@@ -193,7 +181,7 @@ impl CommitComponent {
193181
)));
194182
return Ok(());
195183
}
196-
let mut msg = msg;
184+
let mut msg = message_prettify(msg, Some(b'#'))?;
197185
if let HookResult::NotOk(e) =
198186
sync::hooks_commit_msg(CWD, &mut msg)?
199187
{

0 commit comments

Comments
 (0)