Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
damianopetrungaro committed Feb 21, 2018
0 parents commit acf3cf9
Show file tree
Hide file tree
Showing 29 changed files with 3,462 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
30 changes: 30 additions & 0 deletions .php-commitizen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

return [
'type' => [
'lengthMin' => 1,
'lengthMax' => 5,
'acceptExtra' => false,
'values' => ['feat', 'fix'],
],
'scope' => [
'lengthMin' => 0,
'lengthMax' => 10,
'acceptExtra' => true,
'values' => [],
],
'description' => [
'lengthMin' => 1,
'lengthMax' => 44,
],
'subject' => [
'lengthMin' => 1,
'lengthMax' => 50,
],
'body' => [
'wrap' => 72,
],
'footer' => [
'wrap' => 72,
],
];
18 changes: 18 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
build:
environment:
php:
version: 7.1
version: 7.2
tests:
override:
-
command: 'vendor/bin/phpunit --coverage-clover=coverage-file'
coverage:
file: 'coverage-file'
format: 'clover'
checks:
php:
code_rating: true
filter:
excluded_paths:
- "tests/"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Damiano Petrungaro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# PHP Commitizen

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/damianopetrungaro/php-commitizen/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/damianopetrungaro/php-commitizen/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/damianopetrungaro/php-commitizen/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/damianopetrungaro/php-commitizen/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/damianopetrungaro/php-commitizen/badges/build.png?b=master)](https://scrutinizer-ci.com/g/damianopetrungaro/php-commitizen/build-status/master)

Commitizen is a tool built for create good commits for a clean and readable git history.

This tool follow the [Conventional Commit specs](https://conventionalcommits.org/) and some best practices described in [this slides](https://slides.com/damianopetrungaro/working-with-git)

# Installation and usage

You can install it easily with composer

`$ php composer.phar require --dev damianopetrungaro/php-commitizen`

Usage is simple too

`$ php vendor/bin/php-commitizen commit`

You can also
- pass a flag for add all the file to the stage: `-a`
- specify a custom configuration file adding the file path as argument

You can ask for more information using: `$ php vendor/bin/php-commitizen commit --help`

# Configuration file

The configuration file must return an array (or partial override)

```
<?php
return [
'type' => [
'lengthMin' => 1, // Min length of the type
'lengthMax' => 5, // Max length of the type
'acceptExtra' => false, // Allow adding types not listed in 'values' key
'values' => ['feat', 'fix'], // All the values usable as type
],
'scope' => [
'lengthMin' => 0, // Min length of the scope
'lengthMax' => 10, // Max length of the scope
'acceptExtra' => true, // Allow adding scopes not listed in 'values' key
'values' => [], // All the values usable as scope
],
'description' => [
'lengthMin' => 1, // Min length of the description
'lengthMax' => 44, // Max length of the description
],
'subject' => [
'lengthMin' => 1, // Min length of the subject
'lengthMax' => 50, // Max length of the subject
],
'body' => [
'wrap' => 72, // Wrap the body at 72 characters
],
'footer' => [
'wrap' => 72, Wrap the footer at 72 characters
],
];
```
24 changes: 24 additions & 0 deletions bin/php-commitizen
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

use Damianopetrungaro\PHPCommitizen\CreateConventionalCommit;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Output\ConsoleOutput;

foreach ([__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php'] as $autoloadFile) {
if (file_exists($autoloadFile)) {
require $autoloadFile;
break;
}
}

try {
$configuration = require __DIR__ . '/../.php-commitizen.php';
$app = new Application('PHP Commitizen');
$app->add(new \Damianopetrungaro\PHPCommitizen\CommitCommand($configuration, new CreateConventionalCommit()));
$app->run();
} catch (Throwable $e) {
(new ConsoleOutput())->writeln("<error>{$e->getMessage()}</error>");
}
41 changes: 41 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "damianopetrungaro/php-commitizen",
"description": "Help writing Git commit following conventional commit specs",
"keywords": [
"git",
"commit",
"conventionalcommit",
"conventional commit",
"atomic commit",
"atomic"
],
"type": "library",
"require": {
"roave/security-advisories": "dev-master",
"symfony/console": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"php-mock/php-mock-prophecy": "^0.0.2"
},
"license": "MIT",
"authors": [
{
"name": "Damiano Petrungaro",
"email": "damianopetrungaro@gmail.com"
}
],
"autoload": {
"psr-4": {
"Damianopetrungaro\\PHPCommitizen\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Damianopetrungaro\\PHPCommitizen\\": "tests/Unit"
}
},
"bin": [
"bin/php-commitizen"
]
}
Loading

0 comments on commit acf3cf9

Please sign in to comment.