Skip to content

Commit 5c3be96

Browse files
authored
Merge pull request #20 from joaorobertopb/add-php-cs-fixer
Add php-cs-fixer support
2 parents 166de04 + 08a5a88 commit 5c3be96

File tree

7 files changed

+944
-14
lines changed

7 files changed

+944
-14
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
.gitattributes export-ignore
44
.gitignore export-ignore
55
.travis.yml export-ignore
6+
CONTRIBUTING.md export-ignore
67
Dockerfile export-ignore
78
phpunit.xml export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/vendor/
22
/.idea/
33
/test-git-dir/
4+
.php_cs.cache

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ matrix:
88
- php: 7.2
99
fast_finish: true
1010

11+
cache:
12+
directories:
13+
- $HOME/.composer/cache
14+
1115
before_install:
12-
- composer self-update
16+
- phpenv config-rm xdebug.ini || return 0
17+
- travis_retry composer self-update
1318

1419
install:
15-
- composer update --no-interaction
20+
- travis_retry composer update --no-interaction
1621

1722
script:
1823
- composer validate --strict --no-check-lock
24+
- ./vendor/bin/php-cs-fixer fix . -v --dry-run --using-cache=no
1925
- ./vendor/bin/phpunit

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contributing
2+
3+
Contributions are **welcome**!
4+
5+
We accept contributions via Pull Requests on [Github](https://github.com/BrainMaestro/composer-git-hooks/pulls).
6+
7+
## Pull Requests
8+
9+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is run command:
10+
```sh
11+
composer fix-style
12+
```
13+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
14+
15+
- **Document any change in behaviour** - Make sure the [README.md](README.md) and any other relevant documentation are kept up-to-date.
16+
17+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
18+
19+
- **Create feature branches** - Don't ask us to pull from your master branch.
20+
21+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
22+
23+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
24+
25+
## Running Tests
26+
27+
```sh
28+
phpunit
29+
```
30+
31+
**Happy coding**!

README.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# composer-git-hooks
2-
[![Travis](https://img.shields.io/travis/BrainMaestro/composer-git-hooks.svg?style=flat-square)](https://travis-ci.org/BrainMaestro/composer-git-hooks)
3-
[![Packagist](https://img.shields.io/packagist/v/brainmaestro/composer-git-hooks.svg?style=flat-square)](https://packagist.org/packages/brainmaestro/composer-git-hooks)
4-
[![Packagist](https://img.shields.io/packagist/dt/brainmaestro/composer-git-hooks.svg?style=flat-square)](https://packagist.org/packages/brainmaestro/composer-git-hooks)
2+
3+
[![Software License][badge-license]](LICENSE)
4+
[![Travis][badge-travis]][link-travis]
5+
[![Packagist][badge-packagist]][link-packagist]
6+
[![Download][badge-downloads]][link-packagist]
7+
58
> Manage git hooks easily in your composer configuration. This package makes it easy to implement a consistent project-wide usage of git hooks. Specifying hooks in the composer file makes them available for every member of the project team. This provides a consistent environment and behavior for everyone which is great.
69
710
## Install
@@ -45,7 +48,7 @@ Add a `cghooks` script to the `scripts` section of your `composer.json` file. Th
4548

4649
#### Composer Events
4750

48-
Add the following events to your `composer.json` file. The `cghooks` commands will be run every time the events occur. Go to [Composer Command Events](https://getcomposer.org/doc/articles/scripts.md#command-events) for more details about composer's event system.
51+
Add the following events to your `composer.json` file. The `cghooks` commands will be run every time the events occur. Go to [Composer Command Events][link-composer-events] for more details about composer's event system.
4952

5053
```json
5154
{
@@ -107,9 +110,31 @@ Option | Description | Command
107110

108111
Hooks can be tested with `cghooks ${hook}` before adding them. Example `cghooks pre-commit` runs the `pre-commit` hook.
109112

110-
## Related
111-
- [husky](https://github.com/typicode/husky)
113+
## Contributing
114+
115+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
116+
117+
## Credits
112118

119+
- [Ezinwa Okpoechi][link-author]
120+
- [All Contributors][link-contributors]
121+
122+
## Related
123+
- [husky][link-husky]
113124

114125
## License
115-
MIT © Ezinwa Okpoechi
126+
127+
The MIT License (MIT). Please see [License File](LICENSE) for more information.
128+
129+
[badge-downloads]: https://img.shields.io/packagist/dt/brainmaestro/composer-git-hooks.svg?style=flat-square
130+
[badge-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg
131+
[badge-packagist]: https://img.shields.io/packagist/v/brainmaestro/composer-git-hooks.svg?style=flat-square
132+
[badge-stable]: https://poser.pugx.org/your-app-rocks/eloquent-uuid/v/stable
133+
[badge-travis]: https://img.shields.io/travis/BrainMaestro/composer-git-hooks.svg?style=flat-square
134+
135+
[link-author]: https://github.com/BrainMaestro
136+
[link-composer-events]: https://getcomposer.org/doc/articles/scripts.md#command-events
137+
[link-contributors]: ../../contributors
138+
[link-husky]: https://github.com/typicode/husky
139+
[link-packagist]: https://packagist.org/packages/brainmaestro/composer-git-hooks
140+
[link-travis]: https://travis-ci.org/BrainMaestro/composer-git-hooks

composer.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
}
1717
],
1818
"require": {
19+
"php": "^5.6 || >=7.0 <7.3",
1920
"symfony/console": "^3.2 || ^4.0"
2021
},
22+
"require-dev": {
23+
"phpunit/phpunit": "^5.7",
24+
"friendsofphp/php-cs-fixer": "^2.9"
25+
},
2126
"autoload": {
2227
"psr-4": {
2328
"BrainMaestro\\GitHooks\\": "src/"
@@ -29,10 +34,9 @@
2934
}
3035
},
3136
"bin": ["cghooks"],
32-
"require-dev": {
33-
"phpunit/phpunit": "^5.7"
34-
},
3537
"scripts": {
38+
"check-style": "php-cs-fixer fix --using-cache=no --diff --dry-run .",
39+
"fix-style": "php-cs-fixer fix --using-cache=no .",
3640
"pre-commit": "echo about to commit",
3741
"post-commit": "echo just committed"
3842
}

0 commit comments

Comments
 (0)