Skip to content

Commit d2b6f44

Browse files
committed
add release notes for the new props and data structures
1 parent 0efed34 commit d2b6f44

File tree

2 files changed

+78
-65
lines changed

2 files changed

+78
-65
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ It might be helpful to see how this library can help you. Imagine you have a pr
3333
and a CHANGELOG.md file like this:
3434

3535
```md
36-
# Changelog
36+
# Changelog
3737

3838
## 1.0.0 - 2022-01-14
3939

@@ -71,18 +71,25 @@ If your changelog has multiple versions, the latest one will be used.
7171

7272
There's really only one property that matters for these targets, and that's `ChangelogFile`. This needs to point to the Changelog file you want to read, but it defaults to `CHANGELOG.md` in the root of a given project in case you want to adhere to defaults.
7373

74+
| Property | Type | Default Value | Description |
75+
| - | - | - | - |
76+
| ChangelogFile | string | CHANGELOG.md | Points to the changelog file to parse. Note that the default value is set to the _project_ root by default, so a repository-wide changelog would require this property be set to a different value, for example in a Directory.Build.props file |
77+
| GenerateAssemblyBuildDateAttribute | boolean | true | If set, an assembly metadata attribute named "BuildDate" will be generated with the date (YYYY-MM-DD) of the parsed release. |
78+
| GenerateVersionForUnreleasedChanges | boolean | true | If set, the assembly/package version and release notes will be set from Unreleased changes, if any are present. |
79+
7480
## API
7581

7682
When the task runs, it writes several output items and properties:
7783

7884
|Name|Type|Description|
7985
|----|----|-----------|
80-
| UnreleasedChangelog | UnreleasedChangelogData option | If present, there was an 'Unreleased' section in the Changelog. This structure will contain the sections present. |
86+
| UnreleasedChangelog | ReleaseChangelogData option | If present, there was an 'Unreleased' section in the Changelog. This structure will contain the sections present, as well as an auto-incremented version number for this release. |
87+
| UnreleasedReleaseNotes | string option | If present, contains the concatenated list of all Changelog sections for the Unreleased section of the Changelog. This is a convenience property so that you don't have to String.Join all the lines in the `ReleaseChangelogData` structure yourself! |
8188
| CurrentReleaseChangelog | ReleaseChangelogData option | If present, there was at least one released logged in the Changelog. This structure will contain the details of each one. |
8289
| AllReleasedChangelogs | ReleaseChangelogData list | Contains the ordered list of all released in the ChangelogFile, descending. |
83-
| LatestReleaseNotes | string option | If present, contains the concatenated list of all Changelog sections for the latest release. This is a convenience property so that you don't have to String.Join all the lines in the `ReleaseChangelogData` yourself! |
90+
| LatestReleaseNotes | string option | If present, contains the concatenated list of all Changelog sections for the latest release. This is a convenience property so that you don't have to String.Join all the lines in the `ReleaseChangelogData` structure yourself! |
8491

85-
### ChangelogData
92+
### ReleaseChangelogData
8693

8794
This TaskItem has metadata for each of the known sections of a Changelog:
8895

@@ -95,13 +102,6 @@ This TaskItem has metadata for each of the known sections of a Changelog:
95102

96103
In each case, the value of the metadata is the newline-concatenated list of all of the Changelog Entries for that section.
97104

98-
### UnreleasedChangelogData
99-
100-
This structure is a `ChangelogData` with an `Identity` of `"Unreleased"`.
101-
102-
### ReleaseChangelogData
103-
104-
This structure is the same as `ChangelogData`, but it contains two more items of metadata:
105-
105+
In addition,
106106
* the `Identity` of the `TaskItem` is the Semantic Version of the release
107107
* the `Date` of the `TaskItem` is the `YYYY-MM-DD`-formatted date of the release

test/Ionide.KeepAChangelog.Test/Program.fs

Lines changed: 66 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
open System
44
open SemVersion
55
open Expecto
6-
open Ionide.KeepAChangelog.Domain
6+
open Ionide.KeepAChangelog
77

88
let singleRelease =
99
"""## [1.0.0] - 2017-06-20
@@ -18,13 +18,14 @@ let singleRelease =
1818
1919
"""
2020

21-
let singleReleaseExpected =
22-
(SemanticVersion.Parse "1.0.0", DateTime(2017, 06, 20), Some {
23-
ChangelogData.Default with
24-
Added = ["- A"]
25-
Changed = ["- B"]
26-
Removed = ["- C"]
27-
})
21+
let singleReleaseExpected =
22+
(SemanticVersion.Parse "1.0.0",
23+
DateTime(2017, 6, 20),
24+
Some
25+
{ ChangelogData.Default with
26+
Added = [ "- A" ]
27+
Changed = [ "- B" ]
28+
Removed = [ "- C" ] })
2829

2930
let keepAChangelog =
3031
"""# Changelog
@@ -53,14 +54,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5354
5455
"""
5556

56-
let keepAChangelogExpected: Changelogs =
57-
{
58-
Unreleased = None
59-
Releases = [
60-
singleReleaseExpected
61-
SemanticVersion.Parse("0.3.0"), DateTime(2015, 12, 03), Some { ChangelogData.Default with Added = ["- A";"- B";"- C"]}
62-
]
63-
}
57+
let keepAChangelogExpected: Changelogs =
58+
{ Unreleased = None
59+
Releases =
60+
[ singleReleaseExpected
61+
SemanticVersion.Parse("0.3.0"),
62+
DateTime(2015, 12, 3),
63+
Some { ChangelogData.Default with Added = [ "- A"; "- B"; "- C" ] } ] }
6464

6565
let header =
6666
"""# Changelog
@@ -81,18 +81,22 @@ let headerAndUnreleased = header + emptyUnreleased
8181
let headerAndUnreleasedAndRelease = header + emptyUnreleased + singleRelease
8282
let headerAndUnreleasedAndReleaseExpected = None, singleReleaseExpected
8383

84-
let sample1Release = """## [0.3.1] - 8.1.2022
84+
let sample1Release =
85+
"""## [0.3.1] - 8.1.2022
8586
8687
### Added
8788
8889
- Add XmlDocs to the generated package
8990
9091
"""
9192

92-
let sample1ReleaseExpected =
93-
SemanticVersion.Parse "0.3.1", DateTime(2022, 1, 8), Some { ChangelogData.Default with Added = ["- Add XmlDocs to the generated package"] }
93+
let sample1ReleaseExpected =
94+
SemanticVersion.Parse "0.3.1",
95+
DateTime(2022, 1, 8),
96+
Some { ChangelogData.Default with Added = [ "- Add XmlDocs to the generated package" ] }
9497

95-
let sample = """# Changelog
98+
let sample =
99+
"""# Changelog
96100
All notable changes to this project will be documented in this file.
97101
98102
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -124,15 +128,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
124128
* Initial implementation
125129
"""
126130

127-
let sampleExpected: Changelogs = {
128-
Unreleased = None
129-
Releases = [
130-
SemanticVersion.Parse "0.3.1", DateTime(2022, 1, 8), Some { ChangelogData.Default with Added = ["* Add XmlDocs to the generated package"] }
131-
SemanticVersion.Parse "0.3.0", DateTime(2021, 11, 23), Some { ChangelogData.Default with Added = ["* Expose client `CodeAction` caps as CodeActionClientCapabilities. (by @razzmatazz)"; "* Map CodeAction.IsPreferred & CodeAction.Disabled props. (by @razzmatazz)"] }
132-
SemanticVersion.Parse "0.2.0", DateTime(2021, 11, 17), Some { ChangelogData.Default with Added = ["* Add support for `codeAction/resolve` (by @razzmatazz)"] }
133-
SemanticVersion.Parse "0.1.1", DateTime(2021, 11, 15), Some { ChangelogData.Default with Added = ["* Initial implementation"] }
134-
]
135-
}
131+
let sampleExpected: Changelogs =
132+
{ Unreleased = None
133+
Releases =
134+
[ SemanticVersion.Parse "0.3.1",
135+
DateTime(2022, 1, 8),
136+
Some { ChangelogData.Default with Added = [ "* Add XmlDocs to the generated package" ] }
137+
SemanticVersion.Parse "0.3.0",
138+
DateTime(2021, 11, 23),
139+
Some
140+
{ ChangelogData.Default with
141+
Added =
142+
[ "* Expose client `CodeAction` caps as CodeActionClientCapabilities. (by @razzmatazz)"
143+
"* Map CodeAction.IsPreferred & CodeAction.Disabled props. (by @razzmatazz)" ] }
144+
SemanticVersion.Parse "0.2.0",
145+
DateTime(2021, 11, 17),
146+
Some { ChangelogData.Default with Added = [ "* Add support for `codeAction/resolve` (by @razzmatazz)" ] }
147+
SemanticVersion.Parse "0.1.1",
148+
DateTime(2021, 11, 15),
149+
Some { ChangelogData.Default with Added = [ "* Initial implementation" ] } ] }
136150

137151
open FParsec
138152
open FParsec.Primitives
@@ -141,32 +155,31 @@ let runSuccess label p text expected =
141155
test $"parsing {label}" {
142156

143157
match FParsec.CharParsers.run p text with
144-
| FParsec.CharParsers.Success (r, _, _) ->
145-
Expect.equal r expected "Should have produced expected value"
146-
| FParsec.CharParsers.Failure (m, _, _) ->
147-
failwithf "%A" m
158+
| FParsec.CharParsers.Success (r, _, _) -> Expect.equal r expected "Should have produced expected value"
159+
| FParsec.CharParsers.Failure (m, _, _) -> failwithf "%A" m
148160
}
149161

150162
[<Tests>]
151-
let tests = testList "parsing examples" [
152-
runSuccess "line entry" Parser.pEntry "- A" "- A"
153-
runSuccess "header" Parser.pHeader header ()
154-
runSuccess "unreleased" Parser.pUnreleased emptyUnreleased None
155-
runSuccess "header and unreleased" (Parser.pHeader >>. Parser.pUnreleased) headerAndUnreleased None
156-
runSuccess "release" Parser.pRelease singleRelease singleReleaseExpected
157-
runSuccess "sample 1 release" Parser.pRelease sample1Release sample1ReleaseExpected
158-
runSuccess
159-
"header and unreleased and released"
160-
(Parser.pHeader >>. Parser.pUnreleased
161-
.>>. Parser.pRelease)
162-
headerAndUnreleasedAndRelease
163-
headerAndUnreleasedAndReleaseExpected
164-
165-
runSuccess "keepachangelog" Parser.pChangeLogs keepAChangelog keepAChangelogExpected
166-
167-
runSuccess "lsp changelog" Parser.pChangeLogs sample sampleExpected
168-
]
163+
let tests =
164+
testList
165+
"parsing examples"
166+
[ runSuccess "line entry" Parser.pEntry "- A" "- A"
167+
runSuccess "header" Parser.pHeader header ()
168+
runSuccess "unreleased" Parser.pUnreleased emptyUnreleased None
169+
runSuccess "header and unreleased" (Parser.pHeader >>. Parser.pUnreleased) headerAndUnreleased None
170+
runSuccess "release" Parser.pRelease singleRelease singleReleaseExpected
171+
runSuccess "sample 1 release" Parser.pRelease sample1Release sample1ReleaseExpected
172+
runSuccess
173+
"header and unreleased and released"
174+
(Parser.pHeader >>. Parser.pUnreleased
175+
.>>. Parser.pRelease)
176+
headerAndUnreleasedAndRelease
177+
headerAndUnreleasedAndReleaseExpected
178+
179+
runSuccess "keepachangelog" Parser.pChangeLogs keepAChangelog keepAChangelogExpected
180+
181+
runSuccess "lsp changelog" Parser.pChangeLogs sample sampleExpected ]
169182

170183
[<EntryPoint>]
171-
let main argv =
172-
runTestsWithCLIArgs Seq.empty argv tests
184+
let main argv =
185+
runTestsWithCLIArgs Seq.empty argv tests

0 commit comments

Comments
 (0)