mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 08:53:16 +00:00
cli: remove redundant string concatenation from parse_bulk_edit_message()
This commit is contained in:
parent
1d482c71b8
commit
f7b8a22c66
1 changed files with 11 additions and 7 deletions
|
@ -17,11 +17,15 @@ use crate::text_util;
|
|||
|
||||
/// Cleanup a description by normalizing line endings, and removing leading and
|
||||
/// trailing blank lines.
|
||||
fn cleanup_description(description: &str) -> String {
|
||||
let description = description
|
||||
.lines()
|
||||
.filter(|line| !line.starts_with("JJ: "))
|
||||
.join("\n");
|
||||
fn cleanup_description_lines<I>(lines: I) -> String
|
||||
where
|
||||
I: IntoIterator,
|
||||
I::Item: AsRef<str>,
|
||||
{
|
||||
let description = lines
|
||||
.into_iter()
|
||||
.filter(|line| !line.as_ref().starts_with("JJ: "))
|
||||
.fold(String::new(), |acc, line| acc + line.as_ref() + "\n");
|
||||
text_util::complete_newline(description.trim_matches('\n'))
|
||||
}
|
||||
|
||||
|
@ -45,7 +49,7 @@ JJ: Lines starting with "JJ: " (like this one) will be removed.
|
|||
settings,
|
||||
)?;
|
||||
|
||||
Ok(cleanup_description(&description))
|
||||
Ok(cleanup_description_lines(description.lines()))
|
||||
}
|
||||
|
||||
/// Edits the descriptions of the given commits in a single editor session.
|
||||
|
@ -144,7 +148,7 @@ where
|
|||
}
|
||||
descriptions.insert(
|
||||
commit_id.clone(),
|
||||
cleanup_description(&description_lines.join("\n")),
|
||||
cleanup_description_lines(&description_lines),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue