Skip to content
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

Add support for format of "Keep a Changelog" #11

Merged
merged 3 commits into from
Dec 6, 2017
Merged

Add support for format of "Keep a Changelog" #11

merged 3 commits into from
Dec 6, 2017

Conversation

koppor
Copy link
Contributor

@koppor koppor commented Nov 18, 2017

Keep a Changelog is an initiative for consistent CHANGELOG.md formatting. It especially includes links to GitHub diffs.

Example Changelog: https://github.com/olivierlacan/keep-a-changelog/blob/master/CHANGELOG.md

This PR adds support for that format.

@koppor
Copy link
Contributor Author

koppor commented Nov 18, 2017

With the detection of the format of Keep a Changelog, this PR does not does not address the example of #1 anymore. I would say that this is acceptable, because it should be easy to convert that concrete example to a format close to "Keep a Changelog".

The result for the linked HISTORY.md is

> Mar 28, 2016

* [#76] - Fix errors in exit handlers called via `onmount.teardown()`.

[v1.2.1]: https://github.com/rstacruz/onmount/compare/v1.2.0...v1.2.1

The spurious markdown link is because the linked HISTORY.md does not put all links to versions to the end of the file. Further, the linked file does not follow the convention to put links to issues es "embedded links" and not the end of the file.

@MoOx
Copy link
Owner

MoOx commented Nov 21, 2017

I use ## all the times as second level title for my release, so not sure it's safe this way. I didn't touch this code for a while.
Here is an example https://github.com/phenomic/phenomic/blob/0.x/CHANGELOG.md#0210---2017-04-01

Do you think your change won't break anything?
Sorry I didn't write any tests haha

@koppor
Copy link
Contributor Author

koppor commented Nov 21, 2017

The good thing is that your ## headings are not links:

grafik

The code checks for links at level 2:

grafik

So, the patch should just add support and break nothing ^^

@MoOx
Copy link
Owner

MoOx commented Nov 28, 2017

Should not break nothing for me. But what about some others that might have links?
Can't we find a better way to detect the format before parsing?
Eg:

  • detect that we have # Changelog
  • detect that ## [ have semver number after?

@koppor
Copy link
Contributor Author

koppor commented Dec 5, 2017

OK, I included a check for the format of "KeepAChangelog" (# Changelog at the first line and a line containing a secon-level-heading with a link having the version as link text).

As a consequence, second-level headings are only regarded if the format is approximately the format of "KeepAChangelog". The edge cases where users use #Changelog and ## [1.3.0], but do something strange such as ### [1.3.1] should be very rare and thus are not treated in the check.

I also added trim() of the body to ensure that no newlines appear at the beginning or the end of the body.

@koppor koppor changed the title Add support for format of "Keep a Changelog" [WIP] Add support for format of "Keep a Changelog" Dec 5, 2017
@koppor koppor changed the title [WIP] Add support for format of "Keep a Changelog" Add support for format of "Keep a Changelog" Dec 5, 2017
@koppor
Copy link
Contributor Author

koppor commented Dec 6, 2017

I successfully released version 1.1.1 of MADR using this patch on Windows 10. So the PR is finally 😇 good to go from my side!

@MoOx MoOx merged commit cf50e4e into MoOx:master Dec 6, 2017
@MoOx
Copy link
Owner

MoOx commented Dec 6, 2017

LGTM, thanks for this work!

@koppor koppor deleted the add-support-for-keep-a-changelog branch December 6, 2017 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants