Open Rasmus-Bertell opened 4 months ago
And my pre-push hook looks like this, it's a very simple implementation but works for now.
<?php
namespace App\Console\GitHooks;
use Closure;
use Igorsgm\GitHooks\Contracts\PrePushHook;
use Igorsgm\GitHooks\Exceptions\HookFailException;
use Igorsgm\GitHooks\Git\Log;
use Illuminate\Support\Facades\Artisan;
class PestPrePushHook implements PrePushHook
{
/**
* Get the name of the hook.
*/
public function getName(): ?string
{
return 'Pest Pre Push Hook';
}
/**
* Execute the Hook.
*
* @param Log $log
* @param Closure $next The next hook in the chain to execute.
* @return mixed|null
*/
public function handle(Log $log, Closure $next)
{
$return = Artisan::call("test");
if ($return !== 0) {
throw new HookFailException("Tests failed");
}
// Run the next hook in the chain
return $next($log);
}
}
And .git/hooks/pre-push
file contents
#!/bin/sh
# Detect whether /dev/tty is available & functional
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then
exec < /dev/tty
fi
php /home/rasmus/xxxxxxxx/xxxxxxxxxxxxxxxxxxxx/artisan git-hooks:pre-push $@ >&2
Seems like this is the same error as in #24 sorry for opening a new issue about the same error. I thought I looked through the open issues but I must have been tired or something.
I have exactly the same issue. I thought I was going crazy. For whatever reason - pre-commit works just fine. But pre-push always runs into this issue no matter how I try circumvent it.
Just a note for anyone encountering this issue, you can circumvent the hooks with --no-verify
flag e.g. git push --no-verify
, if you don't want to disable the hooks while waiting for a fix to this.
Based on https://git-scm.com/docs/githooks#_pre_push.
The hook is called with two parameters which provide the name and location of the destination remote, if a named remote is not being used both values will be the same.
I think this could fixed with the following but I haven't had the chance to test it yet. If it works I'll create a PR, there might be some other hooks affected by the same bug also.
*
* @var string
*/
- protected $signature = 'git-hooks:pre-push';
+ protected $signature = 'git-hooks:pre-push {remote?} {url?}';
/**
* The console command description.
same for me
I completely forgot about this, but I'll create a PR this weekend to fix this issue.
I have a pre-push hook which runs my tests and it works with
php artisan git-hooks:pre-push
command, but when actually pushing with the commandgit push
I get the following error: