ins0 / github-changelog-generator
为您的GitHub仓库创建Markdown版本的变化日志。
v0.3.0
2018-05-04 13:51 UTC
Requires
- php: ~5.4|~7.0
- nategood/commando: ^0.2.8
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-11 16:50:58 UTC
README
根据您的仓库版本、问题和pull请求,为您的仓库创建Markdown版本的变化日志。受到github-changelog-generator(Ruby版)的启发。
安装
Composer
$ composer require ins0/github-changelog-generator
用法
注意: 您可以在这里查看生成的输出示例。
PHP
<?php require_once 'vendor/autoload.php'; $token = '...'; // The token is not required, but is still recommended. $repository = new ins0\GitHub\Repository('ins0/github-changelog-generator', $token); $changelog = new ins0\GitHub\ChangelogGenerator($repository); // The ChangelogGenerator::generate() method does throw // exceptions, so remember to wrap your code in try/catch blocks. try { $handle = fopen('CHANGELOG.md', 'w'); if (!$handle) { throw new RuntimeException('Cannot open file for writing'); } // Write markdown output to file fwrite($handle, $changelog->generate()); fclose($handle); } catch (Exception $e) { // handle exceptions... }
如果您的仓库使用除feature
、bug
或enhancement
之外的标签,您可以自定义它们,如下所示
require_once 'vendor/autoload.php'; $labelMappings = [ ins0\GitHub\ChangelogGenerator::LABEL_TYPE_ADDED => ['feature', 'anotherFeatureLabel'], ins0\GitHub\ChangelogGenerator::LABEL_TYPE_CHANGED => ['enhancement', 'anotherEnhancementLabel'], ins0\GitHub\ChangelogGenerator::LABEL_TYPE_FIXED => ['bug', 'anotherBugLabel'] ]; $changelog = new ins0\GitHub\ChangelogGenerator($repository, $labelMappings);
如果您想自定义部分标题,您可以覆盖内置的标题或添加额外的
require_once 'vendor/autoload.php'; $typeHeadings = [ ins0\GitHub\ChangelogGenerator::LABEL_TYPE_ADDED => '### New stuff!' ]; $changelog = new ins0\GitHub\ChangelogGenerator($repository, [], $labelHeaders);
命令行界面
$ php vendor/bin/github-changelog-generator ins0/github-changelog-generator > CHANGELOG.md
命令行界面
此命令行工具支持输出重定向/管道,除非提供了--file
选项。
必需
[repository]
: 您的GitHub仓库的URL(不带域名)。 例如:ins0/github-changelog-generator
布尔值
- 此工具不使用任何布尔标志。
可选
--token
(-t
): 您的GitHub OAUTH令牌。--file
(-f
): 将输出写入文件。--help
: 访问帮助菜单。
退出代码
0
: 成功1
: 失败
测试
此库使用PHPUnit测试套件。
$ composer test
贡献
请参阅CONTRIBUTING和CONDUCT以获取详细信息。
安全
如果您发现任何安全问题,请通过电子邮件rieger@racecore.de报告,而不是使用问题跟踪器。
致谢
许可证
MIT许可证(MIT)。请参阅LICENSE文件以获取更多信息。