getComposer()->getConfig()->get('bin-dir'); $executable = dirname(__DIR__, 2).$filesystem->ensureValidSlashes('/bin/grumphp'); $composerExecutable = $composerBinDir.'/grumphp'; $filesystem->copy( $filesystem->ensureValidSlashes($executable), $filesystem->ensureValidSlashes($composerExecutable) ); $commandlineArgs = ProcessArgumentsCollection::forExecutable($composerExecutable); $commandlineArgs->add('git:init'); $process = self::fixInternalComposerProcessVersion($commandlineArgs); $process->run(); if (!$process->isSuccessful()) { $event->getIO()->write( 'GrumPHP can not sniff your commits. Did you specify the correct git-dir?' ); $event->getIO()->write(''.$process->getErrorOutput().''); return; } $event->getIO()->write(''.$process->getOutput().''); } /** * Composer contains symfony/process:v2.8 internally * This causes this integration hook to fail. (Since the Process class is being loaded from internal composer PHAR) * @see https://github.com/composer/composer/blob/1.9.1/composer.lock#L772-L773 * * This one can be removed once composer udpates its dependencies to at least symfony/process 3.3 */ private static function fixInternalComposerProcessVersion( ProcessArgumentsCollection $commandlineArgs ): Process { $process = ProcessFactory::fromArguments($commandlineArgs); if (\is_string($process->getCommandLine())) { return $process; } return new Process(ProcessUtils::escapeArguments($commandlineArgs->getValues())); } }