Skip to content

Commit

Permalink
Add [YANKED] tag support
Browse files Browse the repository at this point in the history
  • Loading branch information
MangelMaxime committed Dec 16, 2023
1 parent 06ca4df commit c667d4b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Ionide.KeepAChangelog/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,26 @@ module Parser =

attempt dmyDots <|> ymdDashes

let pYanked: Parser<_> =
opt (pstring "[YANKED]")
|>> function
| None -> false
| Some _ -> true

let pVersion = mdUrl pSemver <|> pSemver

let pRelease: Parser<Release> =
let vPart = skipString "##" >>. spaces1 >>. pVersion
let middle = spaces1 .>> pchar '-' .>> spaces1
let date = pDate .>> skipRestOfLine true
let date = pDate
let yanked = opt spaces1 >>. pYanked
let content = choice [ pData; pNonStructuredData ]

pipe5 vPart middle date (opt (many newline)) (opt content) (fun v _ date _ data ->
pipe6 vPart middle date yanked (opt (many newline)) (opt content) (fun v _ date yanked _ data ->
{ Version = v
Date = date
Data = data
IsYanked = false })
IsYanked = yanked })

let pChangeLogs: Parser<Changelogs, unit> =
let unreleased =
Expand Down
17 changes: 17 additions & 0 deletions test/Ionide.KeepAChangelog.Test/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ let sample1ReleaseExpected =
IsYanked = false
}

let yankedRelease = normalizeNewline """## [0.3.1] - 8.1.2022 [YANKED]
### Added
- Add XmlDocs to the generated package
"""

let yankedReleaseExpected =
{
Version = SemanticVersion.Parse "0.3.1"
Date = DateTime(2022, 1, 8)
Data = Some { ChangelogData.Default with Added = "- Add XmlDocs to the generated package\n\n" }
IsYanked = true
}

let sample = normalizeNewline """# Changelog
All notable changes to this project will be documented in this file.
Expand Down Expand Up @@ -211,6 +227,7 @@ let parsingExamples = testList "parsing examples" [
runSuccess "header and unreleased" (Parser.pHeader >>. Parser.pUnreleased) headerAndUnreleased None
runSuccess "release" Parser.pRelease singleRelease singleReleaseExpected
runSuccess "sample 1 release" Parser.pRelease sample1Release sample1ReleaseExpected
runSuccess "yanked release" Parser.pRelease yankedRelease yankedReleaseExpected
runSuccess
"header and unreleased and released"
(Parser.pHeader >>. Parser.pUnreleased
Expand Down

0 comments on commit c667d4b

Please sign in to comment.