support bracketed version numbers
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Cadey Ratio 2020-07-09 10:06:47 -04:00
parent 33019d2548
commit 2c098d4f23
2 changed files with 17 additions and 2 deletions

View File

@ -24,7 +24,7 @@ pub(crate) fn read(fname: PathBuf, tag: String) -> Result<String> {
let found_tag = String::from_utf8(nd.content.clone())?; let found_tag = String::from_utf8(nd.content.clone())?;
if found_tag == tag { if found_tag == tag || found_tag == format!("[{}]", tag) {
collect = true; collect = true;
} }
} else { } else {
@ -70,7 +70,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[test] #[test]
fn read_changelog() { fn basic() {
let res = super::read("testdata/basic.md".into(), "0.1.0".into()); let res = super::read("testdata/basic.md".into(), "0.1.0".into());
assert!(res.is_ok()); assert!(res.is_ok());
let delta = res.unwrap(); let delta = res.unwrap();
@ -79,4 +79,15 @@ mod tests {
"Hi there this is a test\\!\n### ADDED\n - something\n" "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"
)
}
} }

4
testdata/brackets.md vendored Normal file
View File

@ -0,0 +1,4 @@
## [0.1.0]
Hi there this is a test!
### ADDED
- something