src/Robo/Commands/Setup/SettingsCommand.php
protected function installGitHook($hook) {
    $fs = new Filesystem();
    $project_hook_directory = $this->getConfigValue('repo.root') . "/.git/hooks";
    $project_hook = $project_hook_directory . "/$hook";
    if ($this->getConfigValue('git.hooks.' . $hook)) {
      $this->say("Installing $hook git hook...");
      $hook_source = $this->getConfigValue('git.hooks.' . $hook) . "/$hook";
      $path_to_hook_source = rtrim($fs->makePathRelative($hook_source, $project_hook_directory), '/');

      $result = $this->taskFilesystemStack()
        ->mkdir($this->getConfigValue('repo.root') . '/.git/hooks')
        ->remove($project_hook)
        ->symlink($path_to_hook_source, $project_hook)
        ->stopOnFail()
        ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
        ->run();

      if (!$result->wasSuccessful()) {
        throw new BltException("Unable to install $hook git hook.");
      }
    }
    else {
      if (file_exists($project_hook)) {
        $this->say("Removing disabled $hook git hook...");
        $result = $this->taskFilesystemStack()
          ->remove($project_hook)
          ->stopOnFail()
          ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
          ->run();

        if (!$result->wasSuccessful()) {
          throw new BltException("Unable to remove disabled $hook git hook");
        }
      }
      else {
        $this->say("Skipping installation of $hook git hook...");
      }
    }
  }
protected function installGitHook($hook) {
    $fs = new Filesystem();
    $project_hook_directory = $this->getConfigValue('repo.root') . "/.git/hooks";
    $project_hook = $project_hook_directory . "/$hook";
    if ($this->getConfigValue('git.hooks.' . $hook)) {
      $this->say("Installing $hook git hook...");
      $hook_source = $this->getConfigValue('git.hooks.' . $hook) . "/$hook";
      $path_to_hook_source = rtrim($fs->makePathRelative($hook_source, $project_hook_directory), '/');

      $result = $this->taskFilesystemStack()
        ->mkdir($this->getConfigValue('repo.root') . '/.git/hooks')
        ->remove($project_hook)
        ->symlink($path_to_hook_source, $project_hook)
        ->stopOnFail()
        ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
        ->run();

      if (!$result->wasSuccessful()) {
        throw new BltException("Unable to install $hook git hook.");
      }
    }
    else {
      if (file_exists($project_hook)) {
        $this->say("Removing disabled $hook git hook...");
        $result = $this->taskFilesystemStack()
          ->remove($project_hook)
          ->stopOnFail()
          ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
          ->run();

        if (!$result->wasSuccessful()) {
          throw new BltException("Unable to remove disabled $hook git hook");
        }
      }
      else {
        $this->say("Skipping installation of $hook git hook...");
      }
    }
  }
protected function installGitHook ( $ hook ) { $ fs = new Filesystem ( ) ; $ project_hook_directory = $ this -> getConfigValue ( 'repo.root' ) . "/.git/hooks" ; $ project_hook = $ project_hook_directory . "/$hook" ; if ( $ this -> getConfigValue ( 'git.hooks.' . $ hook ) ) { $ this -> say ( "Installing $hook git hook..." ) ; $ hook_source = $ this -> getConfigValue ( 'git.hooks.' . $ hook ) . "/$hook" ; $ path_to_hook_source = rtrim ( $ fs -> makePathRelative ( $ hook_source , $ project_hook_directory ) , '/' ) ; $ result = $ this -> taskFilesystemStack ( ) -> mkdir ( $ this -> getConfigValue ( 'repo.root' ) . '/.git/hooks' ) -> remove ( $ project_hook ) -> symlink ( $ path_to_hook_source , $ project_hook ) -> stopOnFail ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to install $hook git hook." ) ; } } else { if ( file_exists ( $ project_hook ) ) { $ this -> say ( "Removing disabled $hook git hook..." ) ; $ result = $ this -> taskFilesystemStack ( ) -> remove ( $ project_hook ) -> stopOnFail ( ) -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { throw new BltException ( "Unable to remove disabled $hook git hook" ) ; } } else { $ this -> say ( "Skipping installation of $hook git hook..." ) ; } } }
Installs a given git hook.

This symlinks the hook into the project's .git/hooks directory.

@param string $hook
The git hook to install, e.g., 'pre-commit'.

@throws \Acquia\Blt\Robo\Exceptions\BltException
Installs a given git hook .