From 1a18e99e4c32294f02fad55e3759de13d80f8bca Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Sun, 23 Jun 2024 00:03:41 +0200 Subject: [PATCH] export legacy contents during export --- src/changelog.rs | 15 +++++++++++++-- tests/testdata/changelog_fixed.md | 4 ++++ tests/testdata/changelog_to_be_fixed.md | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/changelog.rs b/src/changelog.rs index f1408c2..95fb322 100644 --- a/src/changelog.rs +++ b/src/changelog.rs @@ -11,6 +11,7 @@ pub struct Changelog { pub path: PathBuf, pub fixed: Vec, comments: Vec, + legacy_contents: Vec, pub releases: Vec, pub problems: Vec, } @@ -47,6 +48,10 @@ impl Changelog { } } + self.legacy_contents + .iter() + .for_each(|l| exported_string.push_str(format!("{}\n", l).as_str())); + exported_string } } @@ -76,6 +81,7 @@ pub fn parse_changelog(config: Config, file_path: &Path) -> Result = Vec::new(); let mut fixed: Vec = Vec::new(); + let mut legacy_contents: Vec = Vec::new(); let mut releases: Vec = Vec::new(); let mut problems: Vec = Vec::new(); @@ -92,9 +98,13 @@ pub fn parse_changelog(config: Config, file_path: &Path) -> Result")?; for line in contents.lines() { + if is_legacy { + legacy_contents.push(line.to_string()); + continue; + } + let trimmed_line = line.trim(); - // TODO: improve this? if enter_comment_regex.is_match(trimmed_line) && !exit_comment_regex.is_match(trimmed_line) { is_comment = true; @@ -133,7 +143,6 @@ pub fn parse_changelog(config: Config, file_path: &Path) -> Result Result