anroots/pgca

此包已被废弃且不再维护。未建议替代包。

分析 Git 提交信息以查找不规范的提交实践并报告违规列表

0.2.1 2015-04-28 04:03 UTC

This package is not auto-updated.

Last update: 2020-08-21 19:49:58 UTC


README

Latest Version Software License Build Status Coverage Status Quality Score Quality Score Total Downloads

一个 CLI 工具,用于分析 Git 提交违规。

本项目旨在通过应用一系列规则来改进您的提交(信息)实践,并在您过于懒惰时向您大喊。

该项目源于看到像“修复一些东西”这样的提交信息以及人们无法编写 好的提交信息 的沮丧。

开发状态: 测试版,持续进行。不稳定的公共 API。可用。

安装

  • 通过 Composer 包含
{ 
  "require": {
    "anroots/pgca": "~0.2"
  }
}
  • config/pgca.yml 复制到项目根目录
  • 自定义 pgca.yml 的内容

使用方法

要分析当前项目的提交历史,请在命令行中运行分析器

athena PhpstormProjects/todo-app ‹develop*› » vendor/bin/pgca analyze       
PGCA report, generated on 2015-04-25 11:01:04
+---------+------------+-------------------------+--------------------------------------------------+
| Commit  | Author     | Commit Message          | Explanation                                      |
+---------+------------+-------------------------+--------------------------------------------------+
| 2dda109 | Ando Roots | Add a note to the RE... | The Summary line should be 50 or less characters |
| 342a207 | Ando Roots | Readme additions        | Commit message is really short                   |
| 8ba29a8 | Ando Roots | Add five new Rules      | Commit message is really short                   |
| a7c97f9 | Ando Roots | Refactor AbstractRul... | The Summary line should be 50 or less characters |
| 9a43610 | Ando Roots | Reformat code           | Commit message is really short                   |
| 2b29b55 | Ando Roots | Allow to pass option... | The Summary line should be 50 or less characters |
| 2efbbe5 | Ando Roots | Add --limit and --fr... | The Summary line should be 50 or less characters |
+---------+------------+-------------------------+--------------------------------------------------+
Found a total of 80 commits, skipped 0 and analyzed 80 of them.
The total score was 7

您可以在 pgca.yml 文件和 CLI 选项中自定义分析。

将“简单”报告以表格格式打印到控制台并分析当前分支的最后 40 个 Git 提交

$ vendor/bin/pgca analyze --report-printer=console --report-serializer=console --report-composer=simple --provider-revision=HEAD~40..HEAD                                                                                       1 ↵
PGCA report, generated on 2015-04-12 15:08:06
+---------+------------+-------------------------+--------------------------------------------------+
| Commit  | Author     | Commit Message          | Explanation                                      |
+---------+------------+-------------------------+--------------------------------------------------+
| 342a207 | Ando Roots | Readme additions        | Commit message is really short                   |
| 8ba29a8 | Ando Roots | Add five new Rules      | Commit message is really short                   |
| a7c97f9 | Ando Roots | Refactor AbstractRul... | The Summary line should be 50 or less characters |
+---------+------------+-------------------------+--------------------------------------------------+
Found a total of 40 commits, skipped 0 and analyzed 40 of them.
The total score was 3

文档

请参阅 Wiki 获取更多文档。

要求

规则

请参阅 Wiki 了解标准规则的文档。要获取可用的规则列表,请运行 vendor/bin/pgca/rules:list

$ vendor/bin/pgca rules:list
+-------------------------------------+----------+
| Name                                | Category |
+-------------------------------------+----------+
| message.hasSummaryAndDescription    | Message  |
| message.isLongEnough                | Message  |
| message.startsWithCapitalLetter     | Message  |
| message.summaryFiftyOrLessChars     | Message  |
| message.oneBlankLineAfterSummary    | Message  |
| message.noTrailingWhitespace        | Message  |
| message.noTrailingNewline           | Message  |
| message.noDoubleWhitespace          | Message  |
| message.allLinesLessThanThreshold   | Message  |
| message.notTypicalNonsense          | Message  |
| message.noProfanity                 | Message  |
| message.noProfanity                 | Message  |
| message.summaryDoesNotEndWithPeriod | Message  |
| content.hasNoIgnoredFiles           | Content  |
+-------------------------------------+----------+

测试

$ phpunit

贡献

请参阅 CONTRIBUTING 了解详情。

待办事项

这些是需要改进的更广泛主题,计划在不久的将来进行

规则实现

  • [消息] 摘要处于现在/祈使形式
  • [消息] 在提交信息中包含票据引用
  • [消息] 使用英语
  • [内容] 提交不包含过多的更改文件数(更改 100 个文件的提交)

重构

  • 添加更多代码文档
  • 增加单元测试覆盖率
  • 重构代码,从 alpha 版本到 1.0 质量版本
  • 改进 HTML 报告
  • 为所有规则添加更长的“解释”块。可能是 2-3 段落,包含示例和为什么存在此特定规则的详细解释

致谢

许可

MIT 许可证(MIT)。请参阅 许可文件 了解更多信息。