The php-git-hooks.yml file is rewritten every time the hooks trigger
Closed this issue · 11 comments
As mentioned earlier, the script should not update the file from which it reads its configuration on each commit.
Instead, it should handle things the same way as the Incenteev ParameterHandler: with a .dist
file from which the configuration is loaded, and a rewrite of the target file, when needed (and not everytime).
👍
php-git-hooks.yml is rewritten only when you execute composer install or composer update.
Incenteev ParameterHandler only work with a level in yaml file, like parameters.yml in symfony. Php-git-hooks.yml has more levels.
What I mean is that the file should not be rewritten everytime you run composer install
or composer update
. It should only be written / rewritten if it does not exist, or if Php-git-hooks.yml
's mtime is greater than the dist
file. Also, using a dist
file would let us put Php-git-hooks.yml
it the .gitignore
, which means the file being modified wouldn't matter anymore.
Currently, the file is updated on each composer install
or composer update
, which means that whenever someone installs the project (which happens obviously on the initial checkout), the file is flagged as modified, which is not what we expect.
Only is modified if your php-git-hooks.yml not containts the correct structure. If your file is right, with all keys expected, script not modify file.
Is the same like Incenteev ParameterHandler
The file is not only modified when the structure is right. It is modified all the time. Which means that if you inline the configuration (yaml is very permissive in that regard), it will be modified regardless.
I have the same experience as @csarrazi
@csarrazi Could you write an example?.
I'm testing it and I can see that works fine.
pre-commit:
enabled: true
execute: { composer: true, jsonlint: false, phplint: true, phpmd: true, phpcs: { enabled: true, standard: PSR2 }, php-cs-fixer: { enabled: true, levels: { psr0: true, psr1: true, psr2: true, symfony: true } }, phpunit: { enabled: false, random-mode: false } }
commit-msg:
enabled: false
Ok. Your php-git-hooks.yml file needs more keys for pre-commit config. Last version add message key.
If your execute composer install your php-git-hooks.yml will be like:
pre-commit:
enabled: true
execute: { composer: true, jsonlint: false, phplint: true, phpmd: true, phpcs: { enabled: true, standard: PSR2 }, php-cs-fixer: { enabled: true, levels: { psr0: true, psr1: true, psr2: true, symfony: true } }, phpunit: { enabled: false, random-mode: false } }
message: { right-message: 'HEY, GOOD JOB!!', error-message: 'FIX YOUR FUCKING CODE!!' }
commit-msg:
enabled: false
Other keys from pre-commit will not be modified.
Exactly!
Then, it works fine.