Skip to content

Commit acf3cf9

Browse files
Initial commit
0 parents  commit acf3cf9

29 files changed

+3462
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

.php-commitizen.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
return [
4+
'type' => [
5+
'lengthMin' => 1,
6+
'lengthMax' => 5,
7+
'acceptExtra' => false,
8+
'values' => ['feat', 'fix'],
9+
],
10+
'scope' => [
11+
'lengthMin' => 0,
12+
'lengthMax' => 10,
13+
'acceptExtra' => true,
14+
'values' => [],
15+
],
16+
'description' => [
17+
'lengthMin' => 1,
18+
'lengthMax' => 44,
19+
],
20+
'subject' => [
21+
'lengthMin' => 1,
22+
'lengthMax' => 50,
23+
],
24+
'body' => [
25+
'wrap' => 72,
26+
],
27+
'footer' => [
28+
'wrap' => 72,
29+
],
30+
];

.scrutinizer.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
build:
2+
environment:
3+
php:
4+
version: 7.1
5+
version: 7.2
6+
tests:
7+
override:
8+
-
9+
command: 'vendor/bin/phpunit --coverage-clover=coverage-file'
10+
coverage:
11+
file: 'coverage-file'
12+
format: 'clover'
13+
checks:
14+
php:
15+
code_rating: true
16+
filter:
17+
excluded_paths:
18+
- "tests/"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Damiano Petrungaro
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# PHP Commitizen
2+
3+
[![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)
4+
[![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)
5+
[![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)
6+
7+
Commitizen is a tool built for create good commits for a clean and readable git history.
8+
9+
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)
10+
11+
# Installation and usage
12+
13+
You can install it easily with composer
14+
15+
`$ php composer.phar require --dev damianopetrungaro/php-commitizen`
16+
17+
Usage is simple too
18+
19+
`$ php vendor/bin/php-commitizen commit`
20+
21+
You can also
22+
- pass a flag for add all the file to the stage: `-a`
23+
- specify a custom configuration file adding the file path as argument
24+
25+
You can ask for more information using: `$ php vendor/bin/php-commitizen commit --help`
26+
27+
# Configuration file
28+
29+
The configuration file must return an array (or partial override)
30+
31+
```
32+
<?php
33+
34+
return [
35+
'type' => [
36+
'lengthMin' => 1, // Min length of the type
37+
'lengthMax' => 5, // Max length of the type
38+
'acceptExtra' => false, // Allow adding types not listed in 'values' key
39+
'values' => ['feat', 'fix'], // All the values usable as type
40+
],
41+
'scope' => [
42+
'lengthMin' => 0, // Min length of the scope
43+
'lengthMax' => 10, // Max length of the scope
44+
'acceptExtra' => true, // Allow adding scopes not listed in 'values' key
45+
'values' => [], // All the values usable as scope
46+
],
47+
'description' => [
48+
'lengthMin' => 1, // Min length of the description
49+
'lengthMax' => 44, // Max length of the description
50+
],
51+
'subject' => [
52+
'lengthMin' => 1, // Min length of the subject
53+
'lengthMax' => 50, // Max length of the subject
54+
],
55+
'body' => [
56+
'wrap' => 72, // Wrap the body at 72 characters
57+
],
58+
'footer' => [
59+
'wrap' => 72, Wrap the footer at 72 characters
60+
],
61+
];
62+
```

bin/php-commitizen

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
declare(strict_types=1);
5+
6+
use Damianopetrungaro\PHPCommitizen\CreateConventionalCommit;
7+
use Symfony\Component\Console\Application;
8+
use Symfony\Component\Console\Output\ConsoleOutput;
9+
10+
foreach ([__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php'] as $autoloadFile) {
11+
if (file_exists($autoloadFile)) {
12+
require $autoloadFile;
13+
break;
14+
}
15+
}
16+
17+
try {
18+
$configuration = require __DIR__ . '/../.php-commitizen.php';
19+
$app = new Application('PHP Commitizen');
20+
$app->add(new \Damianopetrungaro\PHPCommitizen\CommitCommand($configuration, new CreateConventionalCommit()));
21+
$app->run();
22+
} catch (Throwable $e) {
23+
(new ConsoleOutput())->writeln("<error>{$e->getMessage()}</error>");
24+
}

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "damianopetrungaro/php-commitizen",
3+
"description": "Help writing Git commit following conventional commit specs",
4+
"keywords": [
5+
"git",
6+
"commit",
7+
"conventionalcommit",
8+
"conventional commit",
9+
"atomic commit",
10+
"atomic"
11+
],
12+
"type": "library",
13+
"require": {
14+
"roave/security-advisories": "dev-master",
15+
"symfony/console": "^4.0"
16+
},
17+
"require-dev": {
18+
"phpunit/phpunit": "^7.0",
19+
"php-mock/php-mock-prophecy": "^0.0.2"
20+
},
21+
"license": "MIT",
22+
"authors": [
23+
{
24+
"name": "Damiano Petrungaro",
25+
"email": "[email protected]"
26+
}
27+
],
28+
"autoload": {
29+
"psr-4": {
30+
"Damianopetrungaro\\PHPCommitizen\\": "src/"
31+
}
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"Damianopetrungaro\\PHPCommitizen\\": "tests/Unit"
36+
}
37+
},
38+
"bin": [
39+
"bin/php-commitizen"
40+
]
41+
}

0 commit comments

Comments
 (0)