/** * {@inheritdoc} */ public function run($callback = null) { $event = new Event\GitEvent($this->git, $this, $this->command); $dispatcher = $this->git->getDispatcher(); try { // Throw the "git.command.prepare" event prior to executing. $dispatcher->dispatch(Event\GitEvents::GIT_PREPARE, $event); // Execute command if it is not flagged to be bypassed and throw the // "git.command.success" event, otherwise do not execute the comamnd // and throw the "git.command.bypass" event. if ($this->command->notBypassed()) { parent::run($callback); if ($this->isSuccessful()) { $dispatcher->dispatch(Event\GitEvents::GIT_SUCCESS, $event); } else { $output = $this->getErrorOutput(); if (trim($output) == '') { $output = $this->getOutput(); } throw new \RuntimeException($output); } } else { $dispatcher->dispatch(Event\GitEvents::GIT_BYPASS, $event); } } catch (\RuntimeException $e) { $dispatcher->dispatch(Event\GitEvents::GIT_ERROR, $event); throw new GitException($e->getMessage()); } }
/** * Adds the bypass listener so that Git commands are not run. * * @return TestBypassListener */ public function addBypassListener() { $listener = new TestBypassListener(); $dispatcher = $this->_wrapper->getDispatcher(); $dispatcher->addListener(GitEvents::GIT_PREPARE, array($listener, 'onPrepare'), -5); return $listener; }