Skip to content

Commit 259a925

Browse files
authored
Merge pull request #18 from Cheppers/core-hooks-path
Core hooks path
2 parents cd3fc70 + 616e95c commit 259a925

31 files changed

+484
-891
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
/fixtures/git-template/hooks/
32
/fixtures/project-template/*/vendor/
43

54
/release/

README.md

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ teammates then this is the tool you are looking for.
1717
## How to use
1818

1919
1. Step into you existing package's directory (or create a new one with `git init && composer init`)
20-
1. See the example `composer.json` below and copy the `repositories` part to
21-
your `composer.json`.
22-
1. Run <pre><code>composer require --dev \
23-
'bernardosilva/git-hooks-installer-plugin' \
24-
'codegyre/robo'</code></pre>
25-
1. Run <pre><code>composer require --dev 'cheppers/git-hooks'</code></pre>
26-
1. Create a `.git-hooks` file. See the example bellow.
27-
1. Create a `RoboFile.php`. See the example bellow.
20+
1. Run <pre><code>composer require 'cheppers/git-hooks'</code></pre>
21+
1. Then you have two option
22+
1. Relay on the git hooks scripts which are shipped with this package
23+
and implement the logic in your `.git-hooks` file.
24+
1. Or create a `git-hooks` directory and create git hook files (`git-hooks/pre-commit`) in it.
25+
1. And trigger the deployment script on the `post-install-cmd` event.
2826

2927

3028
## Example composer.json
@@ -37,32 +35,45 @@ teammates then this is the tool you are looking for.
3735
"license": "GPL-2.0",
3836
"minimum-stability": "dev",
3937
"prefer-stable": true,
40-
"require": {},
41-
"require-dev": {},
42-
"repositories": [
43-
{
44-
"type": "package",
45-
"package": {
46-
"name": "cheppers/git-hooks",
47-
"version": "0.0.5",
48-
"type": "git-hook",
49-
"dist": {
50-
"type": "tar",
51-
"url": "https://github.com/Cheppers/git-hooks/releases/download/v0.0.5/v0.0.5.tar.gz"
52-
},
53-
"source": {
54-
"type": "git",
55-
"url": "https://github.com/Cheppers/git-hooks.git",
56-
"reference": "v0.0.5"
57-
}
58-
}
38+
"require": {
39+
"cheppers/git-hooks": "dev-master"
40+
},
41+
"scripts": {
42+
"post-install-cmd": [
43+
"@deploy-git-hooks"
44+
],
45+
"deploy-git-hooks": "\\Cheppers\\GitHooks\\Main::deploy"
46+
},
47+
"extra": {
48+
"cheppers/git-hooks": {
49+
"core.hooksPath": "git-hooks",
50+
"symlink": false
5951
}
60-
]
52+
}
6153
}
6254
```
6355

6456

65-
# Example .git-hooks
57+
# Configuration
58+
59+
In the example `composer.json` above you can see two configurable option
60+
under the `"extra": {"cheppers/git-hooks": {}}`.
61+
62+
63+
## Configuration symlink
64+
65+
This option will be used when you have a `git-hooks` directory.
66+
67+
68+
## Configuration core.hooksPath
69+
70+
When this option is `true` then it allows to use the new feature of the Git v2.9
71+
72+
Actually if you and all of your development team use Git v2.9 then you don't need
73+
this package at all.
74+
75+
76+
# Example .git-hooks for Robo task runner
6677

6778
```bash
6879
#!/usr/bin/env bash

RoboFile.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,14 @@ public function githookPreCommit()
194194
*/
195195
protected function getTaskPhpcsLint()
196196
{
197-
$cmd_pattern = '%s --standard=%s --ignore=%s %s %s %s';
197+
$cmd_pattern = '%s --standard=%s --ignore=%s %s %s %s %s';
198198
$cmd_args = [
199199
escapeshellcmd("{$this->binDir}/phpcs"),
200200
escapeshellarg('PSR2'),
201201
escapeshellarg('fixtures/project-template/*/vendor/'),
202202
escapeshellarg('features/bootstrap/'),
203203
escapeshellarg('fixtures/project-template/'),
204+
escapeshellarg('src/'),
204205
escapeshellarg('RoboFile.php'),
205206
];
206207

composer.json

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,20 @@
1515
"symfony/filesystem": "~3.1",
1616
"symfony/process": "~3.1"
1717
},
18-
"archive": {
19-
"exclude": [
20-
"/*",
21-
"/.*",
22-
"!/hooks/_common",
23-
"!/hooks/applypatch-msg",
24-
"!/hooks/commit-msg",
25-
"!/hooks/post-applypatch",
26-
"!/hooks/post-checkout",
27-
"!/hooks/post-commit",
28-
"!/hooks/post-merge",
29-
"!/hooks/post-receive",
30-
"!/hooks/post-rewrite",
31-
"!/hooks/post-update",
32-
"!/hooks/pre-applypatch",
33-
"!/hooks/pre-auto-gc",
34-
"!/hooks/pre-commit",
35-
"!/hooks/pre-push",
36-
"!/hooks/pre-rebase",
37-
"!/hooks/pre-receive",
38-
"!/hooks/prepare-commit-msg",
39-
"!/hooks/push-to-checkout",
40-
"!/hooks/update",
41-
"!/composer.json",
42-
"!/README.md"
43-
]
18+
"autoload": {
19+
"psr-4": {
20+
"Cheppers\\GitHooks\\": "src/"
21+
}
4422
},
4523
"scripts": {
46-
"post-install-cmd": "robo deploy:git-hooks"
24+
"post-install-cmd": [
25+
"@deploy-git-hooks"
26+
],
27+
"deploy-git-hooks": "\\Cheppers\\GitHooks\\Main::deploy"
28+
},
29+
"extra": {
30+
"cheppers/git-hooks": {
31+
"symlink": true
32+
}
4733
}
4834
}

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)