forked from mirrors/jj
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.
|
||||
// TODO: Tell the user the name of the file we left behind.
|
||||
std::fs::remove_file(description_file_path).ok();
|
||||
let lines: Vec<_> = description
|
||||
let mut lines: Vec<_> = description
|
||||
.split_inclusive('\n')
|
||||
.filter(|line| !line.starts_with("JJ: "))
|
||||
.collect();
|
||||
// Remove trailing blank lines
|
||||
while matches!(lines.last(), Some(&"\n") | Some(&"\r\n")) {
|
||||
lines.pop().unwrap();
|
||||
}
|
||||
lines.join("")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue