Comments (5)
Almost 3 months later, I finally get around to trying it out and it works straight away. Thanks for your effort and work Captain Hook!
👍
from captainhook.
There is some magic in place checking if we should use relative or absolute path.
The current approach is: If the Cap'n is located within the git repository it will use a relative path. So you are able to move the directory around without any implications.
If the Cap'n is located outside of your repository I'm currently using an absolute path to archive the same result. Being able to move the source files around without any hassle.
protected function getPathForHookTo(Directory $repo, Path $target): string
{
if (!$target->isChildOf($repo)) {
return '\'' . $target->getPath() . '\'';
}
return '__DIR__ . \'/../../' . $target->getRelativePathFrom($repo) . '\'';
}
I think you are using PHIVE
with symlinks meaning PHP will not look at the symlink path, it will look at the real_path
meaning the path to the real file. This is was real_path
returns.
The config value run-path
is currently only used in Docker
mode.
I like the idea of using it to specify the executable to call and using it as given without any real_path
magic.
A quick fix for you might be to copy the PHAR to ./tools/*
. Not perfect but then the path would be added relative.
<phar name="captainhook" version="^5.9" installed="5.9.1" location="./tools/captainhook" copy="true"/>
I will check if the run-path
value can be used as is and keep you updated here.
from captainhook.
I think this already does it but I will improve the install tests a little bit more.
For now I don't have the best feeling not breaking something for somebody else.
from captainhook.
thanks for your thoughts and efforts so far.
Currently I use the following workaround. I have a small bash script anyway that installs all the necessary tools via phive. I have now extended this. We currently only use the pre-commit hook, so this fits for us.
echo "Run Captain Hook installation"
./tools/captainhook install --configuration=./captainhook.json pre-commit
echo ""
echo "Fix absolute path for Captain Hook in commit hook to local one"
HOOK_FILE=".git/hooks/pre-commit"
if [ -f "$HOOK_FILE" ]; then
sed -i "s|$HOME/.phive/phars/captainhook-[0-9]*\.[0-9]*\.[0-9]*\.phar|./tools/captainhook|" "$HOOK_FILE"
echo "The path in $HOOK_FILE was fixed."
else
echo "Error: $HOOK_FILE does not exist."
fi
The workaround currently works in the team. But of course it would be great if the Cap'n also offers an official way to solve the problem.
from captainhook.
You can use relative path now by configuring it in run-cmd
to overwrite the absolute path behavior.
Release with 5.17.0
from captainhook.
Related Issues (20)
- 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
- Docker mode not working? HOT 9
- 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.