Skip to content

Commit

Permalink
[Bugfix] RONLOG: Do not Discard Continued Lines in RST Fragments (#1062)
Browse files Browse the repository at this point in the history
* Fixed ::= Fragment::from_rst:  do not discard continued lines

* Fixed ::= test case for Fragment::from_rst

* Create summary of recent changes

---------

Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kevinmatthes and github-actions[bot] committed Jan 9, 2024
1 parent a4f1e33 commit 5c1b905
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(
references: {},
changes: {
"Fixed": [
"Fragment::from_rst: do not discard continued lines",
"test case for Fragment::from_rst",
],
},
)
12 changes: 10 additions & 2 deletions src/changelog/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl Fragment {
impl crate::FromRst for Fragment {
fn from_rst(rst: &str) -> Result<Self> {
let mut category = String::new();
let mut change = String::new();
let mut previous_line = String::new();
let mut result = Self::default();

Expand All @@ -146,9 +147,16 @@ impl crate::FromRst for Fragment {
} else if line.starts_with(|c| "*-".contains(c))
&& !category.is_empty()
{
if let Some(change) = line.strip_prefix(|c| "*-".contains(c)) {
result.insert(category.trim(), change.trim());
if let Some(new_change) =
line.strip_prefix(|c| "*-".contains(c))
{
change.append_as_line(new_change);
}
} else if line.starts_with(" ") && !line.trim().is_empty() {
change.append_as_line(line);
} else if line.trim().is_empty() && !change.is_empty() {
result.insert(category.trim(), change.trim());
change.clear();
}

previous_line = line.to_string();
Expand Down
3 changes: 3 additions & 0 deletions tests/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Added
Fixed
.....
- another bug ...
... whose description takes two lines
- known bug in `d.rs`_
";
Expand Down

0 comments on commit 5c1b905

Please sign in to comment.