mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 08:53:16 +00:00
cli: remove trailing blank lines from commit description after editing
This commit is contained in:
parent
f96130d21c
commit
e29cef7918
1 changed files with 5 additions and 1 deletions
|
@ -1348,10 +1348,14 @@ fn edit_description(repo: &ReadonlyRepo, description: &str) -> String {
|
||||||
// Delete the file only if everything went well.
|
// Delete the file only if everything went well.
|
||||||
// TODO: Tell the user the name of the file we left behind.
|
// TODO: Tell the user the name of the file we left behind.
|
||||||
std::fs::remove_file(description_file_path).ok();
|
std::fs::remove_file(description_file_path).ok();
|
||||||
let lines: Vec<_> = description
|
let mut lines: Vec<_> = description
|
||||||
.split_inclusive('\n')
|
.split_inclusive('\n')
|
||||||
.filter(|line| !line.starts_with("JJ: "))
|
.filter(|line| !line.starts_with("JJ: "))
|
||||||
.collect();
|
.collect();
|
||||||
|
// Remove trailing blank lines
|
||||||
|
while matches!(lines.last(), Some(&"\n") | Some(&"\r\n")) {
|
||||||
|
lines.pop().unwrap();
|
||||||
|
}
|
||||||
lines.join("")
|
lines.join("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue