Skip to content

Commit

Permalink
cli: allow any number of trailing dashes in "JJ: describe" line
Browse files Browse the repository at this point in the history
Because a line without " -------" is allowed, it makes sense to strip other
variants like " --".
  • Loading branch information
yuja committed Aug 6, 2024
1 parent fb3e120 commit 0b1a6cd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cli/src/description_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ where
let mut messages: Vec<(&str, Vec<&str>)> = vec![];
for line in message.lines() {
if let Some(commit_id_prefix) = line.strip_prefix("JJ: describe ") {
let commit_id_prefix = commit_id_prefix.trim_end_matches(" -------");
let commit_id_prefix =
commit_id_prefix.trim_end_matches(|c: char| c.is_ascii_whitespace() || c == '-');
messages.push((commit_id_prefix, vec![]));
} else if let Some((_, lines)) = messages.last_mut() {
lines.push(line);
Expand Down Expand Up @@ -257,12 +258,16 @@ mod tests {
JJ: describe 1 -------
Description 1
JJ: describe 2 -------
JJ: describe 2
Description 2
JJ: describe 3 --
Description 3
"},
&indexmap! {
"1".to_string() => &1,
"2".to_string() => &2,
"3".to_string() => &3,
},
)
.unwrap();
Expand All @@ -271,6 +276,7 @@ mod tests {
hashmap! {
1 => "Description 1\n".to_string(),
2 => "Description 2\n".to_string(),
3 => "Description 3\n".to_string(),
}
);
assert!(result.missing.is_empty());
Expand Down

0 comments on commit 0b1a6cd

Please sign in to comment.