[Question] Cannot specify git directory with composer plugin
miguel-is-coding opened this issue · comments
Recently we have tried to add captainhook to our project, currently using a dockerized project with a PHP container, so for that reason, we used the following command as we use docker, and we have .git folder one level above the src.
vendor/bin/captainhook install --run-mode=docker --run-exec="docker exec elmo-beta-php" --git-directory=../.git
The thing is, we wanted to use the plugin suggested in the docs, so the team will have the hooks activated in their local repository. But we found out that we cannot specify the git directory this way.
Maybe are we missing something? It's possible that the install command should be executed first and then install the composer plugin?
We have tried to create a symbolic link of our .git inside the src folder, but turns out is not possible.
Any suggestion will be gladly received!
Thanks in advance and thanks for create this repo :)
I would expect that the Composer plugin tries to detect the .git
directory by looking from the current working directory upwards. So if your CWD is /some/path
the plugin will look for /some/path/.git
, /some/.git
and /.git
. Would be interesting to see the hooks the install
command generates. Of is it the install that already fails with the Composer plugin?
If you just want everybody to have the hooks installed you do not need the plugin, you can just add this to your composer.json
.
{
"scripts": {
"post-autoload-dump": "vendor/bin/captainhook install ..."
}
}
This will install the hooks every time the autoloader is generated. You could use any preferred Composer event to trigger this post-install
, post-update
...
If you still want to use the plugin I would have to take a look at the generated hooks to figure out where the path mapping went wrong.
Finally we decided to avoid to use the composer plugin, and try to run and approach using the post-autoload-dump
you mentioned.
But we found a problem when the autoload is runned, due the docker limitation where the root path is /var/www/html
, and having the .git folder outside the docker container.
So with that approach, we are having the following error throwed out:
Invalid git repository: /var/www/html
Is there a possible workaround to overcome this?
The Docker container must have access to the .git
directory. Otherwise the Cap'n running inside the container has no chance of executing git commands to know what is what.