Skip to content

Commit e80e167

Browse files
authored
Merge pull request #24 from Sweetchuck/i23-composer-plugin
composer plugin
2 parents 7848685 + 19d65be commit e80e167

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3514
-1371
lines changed

.circleci/config.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,19 @@ commands:
4545
restore_cache:
4646
name: 'Composer - cache restore'
4747
keys:
48-
- 'composer-{{ checksum "./composer.lock" }}-1'
48+
- 'composer-{{ checksum "./composer.lock" }}-2'
4949

5050
-
5151
run:
5252
name: 'Composer - install'
5353
command: >
54-
[[ -d "$(composer config vendor-dir)" ]] || composer install --no-progress
54+
composer install --no-progress --ansi
5555
5656
-
5757
save_cache:
5858
name: 'Composer - cache save'
59-
key: 'composer-{{ checksum "./composer.lock" }}-1'
59+
key: 'composer-{{ checksum "./composer.lock" }}-2'
6060
paths:
61-
- './bin/'
62-
- './vendor/'
6361
- '~/.composer/cache/'
6462

6563

@@ -69,25 +67,27 @@ commands:
6967
-
7068
run:
7169
name: 'Run linters'
72-
command: 'bin/robo lint'
70+
command: 'bin/robo --ansi lint'
7371

7472
test:
7573
description: 'Run tests'
7674
steps:
7775
-
7876
run:
79-
name: 'Git config user.name and user.email'
80-
command: |
81-
git config --global user.name 'Circle CI'
82-
git config --global user.email '[email protected]'
83-
-
84-
run:
85-
name: 'Run Behat tests'
86-
command: 'bin/robo test'
87-
-
88-
store_test_results:
77+
name: 'Codeception - unit'
78+
command: 'bin/robo --ansi test unit'
79+
- codecov/upload:
80+
flags: 'unit'
81+
file: './tests/_output/machine/coverage/unit/coverage.xml'
82+
- run:
83+
name: 'Codeception - acceptance'
84+
command: 'bin/robo --ansi test acceptance'
85+
- codecov/upload:
86+
flags: 'acceptance'
87+
file: './tests/_output/machine/coverage/acceptance/coverage.xml'
88+
- store_test_results:
8989
name: 'Store unit test results'
90-
path: './reports/machine/junit'
90+
path: './tests/_output/machine/junit'
9191

9292
jobs:
9393
build:

.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@ indent_size = 4
88
charset = utf-8
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
11-
12-
[*.feature]
13-
indent_size = 2

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11

22
/bin/
3-
/fixtures/project-template/*/vendor/
3+
44
/reports/
5+
6+
/tests/_data/fixtures/project-template/*/vendor/
7+
/tests/_output/
8+
/tests/_support/_generated/
9+
/tests/*.suite.yml
10+
511
/vendor/
612

13+
/.git-hooks-local
14+
/codeception.yml
15+
/phpcs.xml
716
/sweetchuck-git-hooks-*.tar
817
/sweetchuck-git-hooks-*.zip

README.md

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,87 +19,90 @@ teammates then this is the tool you are looking for.
1919

2020
1. Step into you existing package's directory (or create a new one with `git
2121
init && composer init`)
22-
2. Run `composer require 'sweetchuck/git-hooks'`
22+
2. Run `composer require --dev 'sweetchuck/git-hooks'`
2323
3. Then you have two option
24-
1. Relay on the git hooks scripts which are shipped with this packag and
24+
1. Relay on Git hooks scripts which are shipped with this package and
2525
implement the logic in your `./.git-hooks` file.
2626
2. Or create a `./git-hooks` directory and create Git hook files in it. (eg:
2727
`./git-hooks/pre-commit`)
2828
4. The deployment script will be automatically triggered by the
2929
`post-install-cmd` Composer event.
3030

3131

32-
## Example composer.json
33-
34-
```JSON
35-
{
36-
"require": {
37-
"sweetchuck/git-hooks": "dev-master"
38-
},
39-
"scripts": {
40-
"post-install-cmd": [
41-
"\\Sweetchuck\\GitHooks\\Composer\\Scripts::postInstallCmd"
42-
]
43-
}
44-
}
45-
```
46-
47-
4832
## Configuration
4933

34+
Example composer.json file:
5035
```json
5136
{
5237
"extra": {
5338
"sweetchuck/git-hooks": {
54-
"core.hooksPath": "git-hooks",
55-
"symlink": false
39+
"core.hooksPath": "./git-hooks",
40+
"symlink": true
5641
}
5742
}
5843
}
5944
```
6045

6146

62-
### Configuration - symlink
47+
### Configuration - core.hooksPath
6348

64-
Type: boolean
49+
Type: string
6550

66-
Default value: false
51+
Default value: `vendor/sweetchuck/git-hooks/git-hooks` (dynamically detected)
6752

68-
Copy or symlink Git hook files from the original location to the `./.git/hooks`.
53+
If the Git version is >= v2.9 then this value will be used to set `git config
54+
core.hooksPath <FOO>`. If Git is older than 2.9 then the content of this
55+
directory will be symbolically linked or copied to `./.git/hooks` directory.
6956

7057

71-
### Configuration - core.hooksPath
58+
### Configuration - symlink
7259

73-
Type: string
60+
Type: boolean
7461

75-
Default value: git-hooks
62+
Default value: `false`
7663

77-
When this option is not empty then it allows to use the new feature of the Git
78-
v2.9
64+
This configuration option will be used only if Git version is older than v2.9.
65+
Copy or symlink Git hook files from the original location (provided by the
66+
`core.hooksPath` configuration) to the `./.git/hooks`.
7967

8068

8169
## Example ./.git-hooks file
8270

83-
The file below runs a Robo command corresponding the name of the current Git
84-
hook.
71+
If you use the Git hooks script from this package
72+
(`vendor/sweetchuck/git-hooks/git-hooks`) you will need custom script which
73+
catches Git hooks add triggers something really useful.
8574

75+
Copy the content below into `./.git-hooks`
8676
```bash
8777
#!/usr/bin/env bash
8878

89-
# @todo Better detection for executables: php, composer.phar and robo.
90-
robo="$(composer config 'bin-dir')/robo"
79+
echo "BEGIN Git hook: ${sghHookName}"
80+
81+
function sghExit ()
82+
{
83+
echo "END Git hook: ${sghHookName}"
84+
85+
exit $1
86+
}
87+
88+
# @todo Better detection for executables: php, composer.phar.
89+
sghRobo="$(composer config 'bin-dir')/robo"
90+
91+
test -s "${sghBridge}.local" && . "${sghBridge}.local"
92+
93+
sghTask="githook:${sghHookName}"
9194

9295
# Exit without error if "robo" doesn't exists or it has no corresponding task.
93-
test -x "$robo" || exit 0
94-
"$robo" help "githook:$sghHookName" 1> /dev/null 2>&1 || exit 0
96+
test -x "$sghRobo" || sghExit 0
97+
"${sghRobo}" help "${sghTask}" 1> /dev/null 2>&1 || sghExit 0
9598

9699
if [ "$sghHasInput" = 'true' ]; then
97-
"$robo" "githook:$sghHookName" $@ <<< $(</dev/stdin) || exit $?
100+
"$sghRobo" "${sghTask}" $@ <<< $(</dev/stdin) || sghExit $?
98101
else
99-
"$robo" "githook:$sghHookName" $@ || exit $?
102+
"$sghRobo" "${sghTask}" $@ || sghExit $?
100103
fi
101104

102-
exit 0
105+
sghExit 0
103106
```
104107

105108

@@ -124,8 +127,3 @@ class RoboFile extends \Robo\Tasks
124127
}
125128
}
126129
```
127-
128-
129-
## Links
130-
131-
* https://robo.li/

0 commit comments

Comments
 (0)