Skip to content

Commit

Permalink
Merge pull request #18 from Cheppers/core-hooks-path
Browse files Browse the repository at this point in the history
Core hooks path
  • Loading branch information
Sweetchuck authored Jul 9, 2016
2 parents cd3fc70 + 616e95c commit 259a925
Show file tree
Hide file tree
Showing 31 changed files with 484 additions and 891 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

/fixtures/git-template/hooks/
/fixtures/project-template/*/vendor/

/release/
Expand Down
69 changes: 40 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ teammates then this is the tool you are looking for.
## How to use

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


## Example composer.json
Expand All @@ -37,32 +35,45 @@ teammates then this is the tool you are looking for.
"license": "GPL-2.0",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {},
"require-dev": {},
"repositories": [
{
"type": "package",
"package": {
"name": "cheppers/git-hooks",
"version": "0.0.5",
"type": "git-hook",
"dist": {
"type": "tar",
"url": "https://github.com/Cheppers/git-hooks/releases/download/v0.0.5/v0.0.5.tar.gz"
},
"source": {
"type": "git",
"url": "https://github.com/Cheppers/git-hooks.git",
"reference": "v0.0.5"
}
}
"require": {
"cheppers/git-hooks": "dev-master"
},
"scripts": {
"post-install-cmd": [
"@deploy-git-hooks"
],
"deploy-git-hooks": "\\Cheppers\\GitHooks\\Main::deploy"
},
"extra": {
"cheppers/git-hooks": {
"core.hooksPath": "git-hooks",
"symlink": false
}
]
}
}
```


# Example .git-hooks
# Configuration

In the example `composer.json` above you can see two configurable option
under the `"extra": {"cheppers/git-hooks": {}}`.


## Configuration symlink

This option will be used when you have a `git-hooks` directory.


## Configuration core.hooksPath

When this option is `true` then it allows to use the new feature of the Git v2.9

Actually if you and all of your development team use Git v2.9 then you don't need
this package at all.


# Example .git-hooks for Robo task runner

```bash
#!/usr/bin/env bash
Expand Down
3 changes: 2 additions & 1 deletion RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,14 @@ public function githookPreCommit()
*/
protected function getTaskPhpcsLint()
{
$cmd_pattern = '%s --standard=%s --ignore=%s %s %s %s';
$cmd_pattern = '%s --standard=%s --ignore=%s %s %s %s %s';
$cmd_args = [
escapeshellcmd("{$this->binDir}/phpcs"),
escapeshellarg('PSR2'),
escapeshellarg('fixtures/project-template/*/vendor/'),
escapeshellarg('features/bootstrap/'),
escapeshellarg('fixtures/project-template/'),
escapeshellarg('src/'),
escapeshellarg('RoboFile.php'),
];

Expand Down
40 changes: 13 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,20 @@
"symfony/filesystem": "~3.1",
"symfony/process": "~3.1"
},
"archive": {
"exclude": [
"/*",
"/.*",
"!/hooks/_common",
"!/hooks/applypatch-msg",
"!/hooks/commit-msg",
"!/hooks/post-applypatch",
"!/hooks/post-checkout",
"!/hooks/post-commit",
"!/hooks/post-merge",
"!/hooks/post-receive",
"!/hooks/post-rewrite",
"!/hooks/post-update",
"!/hooks/pre-applypatch",
"!/hooks/pre-auto-gc",
"!/hooks/pre-commit",
"!/hooks/pre-push",
"!/hooks/pre-rebase",
"!/hooks/pre-receive",
"!/hooks/prepare-commit-msg",
"!/hooks/push-to-checkout",
"!/hooks/update",
"!/composer.json",
"!/README.md"
]
"autoload": {
"psr-4": {
"Cheppers\\GitHooks\\": "src/"
}
},
"scripts": {
"post-install-cmd": "robo deploy:git-hooks"
"post-install-cmd": [
"@deploy-git-hooks"
],
"deploy-git-hooks": "\\Cheppers\\GitHooks\\Main::deploy"
},
"extra": {
"cheppers/git-hooks": {
"symlink": true
}
}
}
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 259a925

Please sign in to comment.