-
Notifications
You must be signed in to change notification settings - Fork 583
Parse references at end of changelog as separate part of a changelog. #2779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse references at end of changelog as separate part of a changelog. #2779
Conversation
|
Could you explain when this is used? I'm not familiar with this piece of functionality |
Hello @xperiandri, the When you have a change log like this: # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Changed
- Foo 2
## [0.1.0-pre.2] - 2023-10-19
### Added
- Foo 1
## [0.1.0-pre.1] - 2023-10-11
### Added
- Foo 0
[Unreleased]: https://github.com/florenzen/Foo/compare/v0.1.0-pre.2...HEAD
[0.1.0-pre.2]: https://github.com/florenzen/Foo/releases/tag/v0.1.0-pre.2
[0.1.0-pre.1]: https://github.com/florenzen/Foo/releases/tag/v0.1.0-pre.1and then run the following code, that is a stripped down excerpt from the build code of MiniScaffold to move the unreleased and the pre-release entries to a new release section #r "nuget: Fake.Core.ReleaseNotes"
open System
open System.IO
open Fake.Core
let chglog = Changelog.parse (File.ReadAllLines("CHANGELOG.md"))
let newVersion = SemVer.parse ("0.1.0")
let versionTuple version =
(version.Major, version.Minor, version.Patch)
let prereleaseEntries =
chglog.Entries
|> List.filter (fun entry ->
entry.SemVer.PreRelease.IsSome
&& versionTuple entry.SemVer = versionTuple newVersion)
let prereleaseChanges =
prereleaseEntries |> List.collect (fun entry -> entry.Changes) |> List.distinct
let assemblyVersion, nugetVersion = Changelog.parseVersions newVersion.AsString
let description, unreleasedChanges =
match chglog.Unreleased with
| None -> None, []
| Some u -> u.Description, u.Changes
let newEntry =
Changelog.ChangelogEntry.New(
assemblyVersion.Value,
nugetVersion.Value,
Some DateTime.Today,
description,
unreleasedChanges @ prereleaseChanges,
false
)
let newChangelog =
Changelog.Changelog.New(chglog.Header, chglog.Description, None, newEntry :: chglog.Entries)
File.WriteAllText("CHANGELOG1.md", newChangelog.ToString())you get: # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.1.0] - 2024-07-26
### Changed
- Foo 2
### Added
- Foo 1
- Foo 0
[Unreleased]: https://github.com/florenzen/Foo/compare/v0.1.0-pre.2...HEAD
[0.1.0-pre.2]: https://github.com/florenzen/Foo/releases/tag/v0.1.0-pre.2
[0.1.0-pre.1]: https://github.com/florenzen/Foo/releases/tag/v0.1.0-pre.1
## [0.1.0-pre.2] - 2023-10-19
### Added
- Foo 1
## [0.1.0-pre.1] - 2023-10-11
### Added
- Foo 0
[Unreleased]: https://github.com/florenzen/Foo/compare/v0.1.0-pre.2...HEAD
[0.1.0-pre.2]: https://github.com/florenzen/Foo/releases/tag/v0.1.0-pre.2
[0.1.0-pre.1]: https://github.com/florenzen/Foo/releases/tag/v0.1.0-pre.1All the links from the bottom are part of the By moving them to a separate component of the changeling record type, this does not happen anymore. |
887e7c1 to
ce42a01
Compare
|
@TheAngryByrd any remarks? |
ce42a01 to
90d75b7
Compare
|
Overall love it :) Probably needs some extra tests to make sure we don't mess up files or regress. |
90d75b7 to
137a6f1
Compare
|
Can you give any particular advice? |
@florenzen has an example here that would be useful as a test case. |
|
Should it be added as a test? |
|
I'll add it as a test as soon as I find a minute for it. |
f802046 to
4226bd8
Compare
|
I added several test cases. Glad to receive your feedback on these, @TheAngryByrd. |
|
Any chance of getting this one merged and closed or should I make some more changes to it? |
|
@TheAngryByrd could you have a look? |
b94624d to
a9ef205
Compare
a9ef205 to
eeab39b
Compare
|
@florenzen could you submit release notes file update describing this fix? |
|
@xperiandri, where should I submit the release notes line? I think, it would read like this: Thanks for accepting the contribution. |
|
I’ll push manually, thanks |
Description
The references to tags or
comparelinks at the end of a changelog file are parsed into a separate member of theChangelogrecord. Before, lines likeended up in the
Changeslist of the lastChangelogEntry. In certain situations, this lead to undesired modifications byPromoteUnreleasedsince these reference lines were reproduced in a release entry.When saving and converting a
Changelogto a string, these references are also included as the last lines of the changeling file.