tfarla / changelog-parser
Extract release information from the changelog
Requires
- php: ~7.1
- league/commonmark: ^0.17
Requires (Dev)
- johnkary/phpunit-speedtrap: ^3.0
- php-coveralls/php-coveralls: ^2.0
- phpmd/phpmd: ^2.6
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: ^7.0
- squizlabs/php_codesniffer: ^3.2
This package is auto-updated.
Last update: 2024-11-08 05:01:58 UTC
README
Requirements
- php 7.1 or greater (supported versions)
Why
A changelog contains information about all the changes in a project. This parsers can be used to extract information about a specific release. That information may then be distributed towards your friends, clients, colleagues and other parties.
Installation
composer require tfarla/changelog-parser
Usage
Given we have the following markdown file:
## 1.0.0 - 2018-12-20 ### Added - A cool new feature ### Changed - that thing that was too complex - slow code into fast code ### Removed - A gastly bug
When we parse that markdown file using the MarkdownParser
:
<?php use \TFarla\ChangelogParser\MarkdownParser; $parser = new MarkdownParser(); $result = $parser->parse(file_get_contents('CHANGELOG.md')); foreach ($result->getReleases() as $release) { echo $release->getVersion() . PHP_EOL; echo $release->getDate()->format('Y-m-d') . PHP_EOL; foreach ($release->getChanges() as $type => $changes) { echo $type . PHP_EOL; foreach ($changes as $change) { echo "- $change" . PHP_EOL; } } }
Then we will receive the following output:
1.0.0 2018-12-20 Added - A cool new feature Changed - that thing that was too complex - slow code into fast code Removed - A gastly bug
Tested changelog formats can be found under the tests/fixtures
directory.
Running tests
This project uses golden files to assert expected behaviour.
These golden files should be part stored in the git repository and can be generated by setting the GOLDEN
environment variable to 1
:
GOLDEN=1 composer test
Contributing
Thanks for reading this far into the README and considering contributing to this project. If you have any questions or suggestions feel free to create an issue.
If you want to modify the code then please follow these steps:
- Fork it (https://github.com/TFarla/changelog-parser)
- Create your feature branch (git checkout -b feature/fooBar)
- Commit your changes (git commit -am 'Add some fooBar')
- Push to the branch (git push origin feature/fooBar)
- Create a new Pull Request