tfarla/changelog-parser

Extract release information from the changelog

0.1.0 2018-05-19 21:44 UTC

README

Packagist Travis Coveralls github license

Requirements

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:

  1. Fork it (https://github.com/TFarla/changelog-parser)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request