Comments (6)
It is possible but the implementation must be different.
You have to check the index
to get the files "that will change" in the upcoming commit.
This is done "manually" inside some Hooks like the linting
hook.
Currently there is no Condition
implementation because I haven't figured out a nice way of naming an implementing it without breaking the current FileChanged
implementations or copy pasting everything :/
from captainhook.
I just released version 5.2.0 with the new Staged All
and Any
conditions that you can use in pre-commit
hooks.
from captainhook.
You are right, now FileChanged
is only executed on post-merge
and post-checkout
.
This is because FileChanged
does not work for any other hook.
The way FileChanged\All
and FileChanged\Any
are implemented make them only applicable for post-merge
and post-checkout
hooks.
Both of them are using git diff
to detect the changed files. And only post-checkout
and post-merge
provide the required ID
s to get a valid response.
It was "working" with other hooks before but not working at all, the conditions where always false.
from captainhook.
So there is no diff in a pre-commit
hook?
Thats interesting.
Any suggestion how to receive the diff in a pre-commit hook of those files which are contained within the commit?
Would also know if there is a way to get all changed files in a pre-push hook. Having a diff between HEAD
and repository version would be great.
from captainhook.
I'll give it a try and if I found a way, I'll contribute back. Thanks so far.
from captainhook.
There is a condition specific for pre-commit
named FilesStaged\OfType
it works similar as FilesChanged\Any
. The condition works in a pre-commit
hook and will only execute the hook if a file of a given file suffix is staged for commit. I'll add Any
and All
there today.
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
- 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.