From 2c098d4f23772f00ddf24d651160f3d773e9daa8 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Thu, 9 Jul 2020 10:06:47 -0400 Subject: [PATCH] support bracketed version numbers --- src/changelog.rs | 15 +++++++++++++-- testdata/brackets.md | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 testdata/brackets.md diff --git a/src/changelog.rs b/src/changelog.rs index 99e068f..3fd66df 100644 --- a/src/changelog.rs +++ b/src/changelog.rs @@ -24,7 +24,7 @@ pub(crate) fn read(fname: PathBuf, tag: String) -> Result { let found_tag = String::from_utf8(nd.content.clone())?; - if found_tag == tag { + if found_tag == tag || found_tag == format!("[{}]", tag) { collect = true; } } else { @@ -70,7 +70,7 @@ where #[cfg(test)] mod tests { #[test] - fn read_changelog() { + fn basic() { let res = super::read("testdata/basic.md".into(), "0.1.0".into()); assert!(res.is_ok()); let delta = res.unwrap(); @@ -79,4 +79,15 @@ mod tests { "Hi there this is a test\\!\n### ADDED\n - something\n" ) } + + #[test] + fn brackets() { + let res = super::read("testdata/brackets.md".into(), "0.1.0".into()); + assert!(res.is_ok()); + let delta = res.unwrap(); + assert_eq!( + delta, + "Hi there this is a test\\!\n### ADDED\n - something\n" + ) + } } diff --git a/testdata/brackets.md b/testdata/brackets.md new file mode 100644 index 0000000..cba7d44 --- /dev/null +++ b/testdata/brackets.md @@ -0,0 +1,4 @@ +## [0.1.0] +Hi there this is a test! +### ADDED +- something