purplebooth/git-github-lint

检查github提交并更新其状态

v1.0.0 2016-08-07 18:56 UTC

README

Scrutinizer Code Quality Build Status Dependency Status Latest Stable Version License

本项目旨在确保您提交到存储库的提交遵循git编码风格。这是一个没有Web前端的库组件。

他们测试的标准是Chris Beams 描述的

它实现的验证包括

  • 使用空行将主题与正文分开
  • 限制主题行长度为50个字符(软限制,硬限制为69个字符)
  • 大写主题行
  • 主题行不以句号结尾
  • 在72个字符处换行正文

入门

先决条件

您需要安装

  • PHP(最低7.0版本)

安装

composer require PurpleBooth/git-github-lint

使用

工具

您可以通过将其用作工具来尝试这个库。您需要在GitHub个人访问令牌页面上生成令牌。

使用


Billies-MacBook-Pro-2:git-github-lint billie$ bin/git-github-lint help git-github-lint:pr
Usage:
  git-github-lint:pr [options] [--] <github-username> <github-repository> <pull-request-id>

Arguments:
  github-username       GitHub Username
  github-repository     GitHub Repository
  pull-request-id       The ID of the pull request

Options:
  -t, --token=TOKEN     The token to authenticate to the API with.
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
 Evaluates a the commits in a pull request and checks that their messages match the style advised by Git. It will then update the "status" in github (that little dot next to the commits).


 Here are some good articles on commit message style:

 * http://chris.beams.io/posts/git-commit/
 * https://git-scm.cn/book/ch5-2.html#Commit-Guidelines
 * https://github.com/blog/926-shiny-new-commit-styles


运行时输出

$ php vendor/bin/git-github-lint git-github-lint:pr \
                                 -t my-token \
                                 PurpleBooth \
                                 git-github-lint \
                                 3

git-github-lint:pr
==================

 // Analysing PR PurpleBooth/git-github-lint#3


 [OK] Finished!

您可以通过查看此存储库的拉取请求来了解实际效果。

您可以使用整个库

<?php

$gitHubClient = new \Github\Client()

/** @var GitHubLint $gitHubLint **/
$gitHubLint = new GitHubLintImplementation($gitHubClient);
$gitHubLint->analyse('PurpleBooth', 'git-github-lint', 3);
// -> The commits on your PR should now be updated with a status

请依赖接口而不是具体实现。具体实现可能改变而不会造成BC破坏,接口的变化将导致主要版本增加,表示BC破坏。

运行测试

要运行编码风格测试

首先检出库,然后运行

composer install

编码风格

我们遵循PSR2,并强制所有函数使用PHPDocs

vendor/bin/phpcs -p --standard=psr2 src/ spec/

单元测试

我们使用PHPSpec进行单元测试

vendor/bin/phpspec run

贡献

请阅读CONTRIBUTING.md,了解我们的行为准则和向我们提交拉取请求的过程。

版本控制

我们使用SemVer进行版本控制。有关可用版本,请参阅此存储库的标签

作者

请参阅参与此项目的贡献者列表

许可

本项目采用MIT许可 - 请参阅LICENSE.md文件以了解详细信息