Comments (9)
Legacy naming party ;)
from captainhook.
What's the error message you get?
Check for example .git/hooks/pre-push
if the path the Cap'n generated are correct.
from captainhook.
Sorry, I just realized I didn't add that. In the host, where the IDE is, I get the following error:
.git/hooks/pre-commit: 7: bin/captainhook: not found
That is the right path for inside the container.
from captainhook.
So, make sure your hook scripts contain the actual docker command.
cat .git/hooks/pre-push
should look like this
#!/bin/sh
# installed by CaptainHook 5.22.1
# read original hook stdIn to pass it in as --input option
input=$(cat)
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then
exec < /dev/tty
fi
docker exec -i my-container-name ./bin/captainhook --bootstrap=vendor/autoload.php --input="$input" hook:pre-push "$@"
If your hook scripts do not actually contain the docker command, its because your configuration is broken.
Try to configure the run settings like this.
{
"config": {
"verbosity": "verbose",
"ansi-colors": true,
"includes": [],
"run-mode": "docker",
"run-exec": "docker exec my-container-name",
"run-cmd": "bin/captainhook",
"bootstrap": "vendor/autoload.php"
},
...
}
from captainhook.
I was using 5.21.2, which by default wouldn't overwrite the hooks, so I wasn't seeing the proper changes if I didn't uninstall the hooks beforehand. 🤦
The problem now is that if composer install
is ran in the container, as our bootstrapping does, the hooks are configured without the Docker command and won't work in the host. Can hook-installer deal with this use case too somehow?
from captainhook.
If you want to execute the same hooks from outside and inside the container sadly not.
It is important that the configuration you use to install must have the correct run-mode
configuration otherwise the default version will be installed, and that is not what you want.
from captainhook.
I can live without being able to commit directly in the container, but the real problem will be CI: the pipeline doesn't use our containers.
If you or anybody else has any suggestions about what to do in this scenario, I'd appreciate it.
EDIT: Maybe read an environment variable during installation to tell it what config to use?
That way, the CI pipeline could use one value and my computer a different one?
PD: what is the shell mode? It still uses PHP, right?
from captainhook.
There are multiple ways to make sure you do not execute hooks in CI
- Do not install the hooks
- Set environment variables like
CI
orCAPTAINHOOK_SKIP_HOOKS
to1
The shell mode writes shell scripts to you hook directory. This shell script calls the PHP directly.
The docker mode writes similar shell scripts, the difference being that docker is called instead of PHP.
from captainhook.
Ahhh, good. I found another env variable this morning but not that one. Are all of them listed somewhere? I can't find them.
One last question: what is the difference between the shell and local modes? They seem to output the same hook.
Thank you for all your help!
from captainhook.
Related Issues (20)
- Support for Relative Path to CaptainHook Executable in Generated Hooks HOT 5
- Allow Staged and Changed files condition to define diff-filter HOT 1
- PHP Fatal error: Argument #2 ($filter) must be of type array HOT 7
- InjectIssueKeyFromBranch does not work as expected HOT 10
- http://captainhook.info is not available anymore? HOT 1
- Support Symfony 7 HOT 2
- $CHANGED_FILES placeholder is empty for first push HOT 1
- [FEATURE-REQUEST] New placeholder `ALL_CHANGED_FILES` HOT 17
- Linting fails when it shouldn't? HOT 3
- Default config file does not work HOT 3
- Error 'The "--input" option does not exist' when rerunning the hooks HOT 1
- captainhook/captainhook-phar failing, prefer captainhook/captainhook in README HOT 3
- Running Hooks in Subrepositories fails HOT 10
- Execute PHAR hook installation without an autoloader HOT 9
- [Feature] Parallel execution of actions HOT 1
- [Bug?] Pre-push hook failing with ddev/docker HOT 4
- Installation not working behind a proxy
- Install fails with a missing class HOT 13
- Hello HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from captainhook.