tfarla / changelog-parser
从变更日志中提取发布信息
0.1.0
2018-05-19 21:44 UTC
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-09-08 04:43:40 UTC
README
需求
- php 7.1 或更高版本 (支持的版本)
原因
变更日志包含关于项目所有变更的信息。这个解析器可以用来提取特定版本的信息。这些信息可以进一步分发给您的朋友、客户、同事和其他相关方。
安装
composer require tfarla/changelog-parser
用法
假设我们有以下 markdown 文件
## 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
当我们使用 MarkdownParser
解析该 markdown 文件时
<?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; } } }
那么我们将得到以下输出
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
已测试的变更日志格式可以在 tests/fixtures
目录下找到。
运行测试
本项目使用 金文件 来断言预期行为。这些金文件应部分存储在 git 仓库中,可以通过设置环境变量 GOLDEN
为 1
来生成
GOLDEN=1 composer test
贡献
感谢您阅读这份 README 到此,并考虑为此项目做出贡献。如果您有任何问题或建议,请随时创建问题。
如果您想修改代码,请按照以下步骤操作
- 将其分叉 (https://github.com/TFarla/changelog-parser)
- 创建您的功能分支 (git checkout -b feature/fooBar)
- 提交您的更改 (git commit -am '添加一些 fooBar')
- 将更改推送到分支 (git push origin feature/fooBar)
- 创建新的 Pull Request