Closed sprankhub closed 1 year ago
Uhh that sounds actually really useful. By running something like git diff --name-only head origin/main
or git diff --name-only STATE_GETTING_PUSHED REMOTE/BRANCH
. we could determine the list of files getting pushed.
It could get a bit tricky because if I understand it correctly you can push to multiple remotes at the "same" time. Given that should be a very rare edge case I still don't want to break anything. I have to run some tests. Let me get back to you.
With version 5.15.0 a new Condition
was added that can be used in pre-push
hooks like this.
It can also be used in all post-change
events like post-rewrite
, post-checkout
and post-merge
{
"action": "phpstan analyse",
"conditions": [
{"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\OfType",
"args": [
"php"
]}
]
}
Thank you so much, @sebastianfeldmann!
Inside
pre-commit
, we can use\CaptainHook\App\Hook\Condition\FileStaged\OfType
to only execute an action if a file of a specific type is staged. I would like to have similar functionality insidepre-push
. I only want to execute an action inpre-push
if a file of a specific type is changed in this push.Do you think this is doable in a sane way? Do you think this is valuable also for others?
Thanks!