src/Robo/Commands/Git/GitCommand.php
public function preCommitHook($changed_files) {
    $collection = $this->collectionBuilder();
    $collection->setProgressIndicator(NULL);
    $collection->addCode(
      function () use ($changed_files) {
        return $this->invokeCommands([
          'tests:phpcs:sniff:files' => ['file_list' => $changed_files],
          'tests:twig:lint:files' => ['file_list' => $changed_files],
          'tests:yaml:lint:files' => ['file_list' => $changed_files],
        ]);
      }
    );

    $changed_files_list = explode("\n", $changed_files);
    if (in_array('composer.json', $changed_files_list)
      || in_array('composer.lock', $changed_files_list)) {
      $collection->addCode(
        function () use ($changed_files) {
          return $this->invokeCommand('tests:composer:validate');
        }
      );
    }

    $result = $collection
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();

    if ($result->wasSuccessful()) {
      $this->say("<info>Your local code has passed git pre-commit validation.</info>");
    }

    return $result;
  }
public function preCommitHook($changed_files) {
    $collection = $this->collectionBuilder();
    $collection->setProgressIndicator(NULL);
    $collection->addCode(
      function () use ($changed_files) {
        return $this->invokeCommands([
          'tests:phpcs:sniff:files' => ['file_list' => $changed_files],
          'tests:twig:lint:files' => ['file_list' => $changed_files],
          'tests:yaml:lint:files' => ['file_list' => $changed_files],
        ]);
      }
    );

    $changed_files_list = explode("\n", $changed_files);
    if (in_array('composer.json', $changed_files_list)
      || in_array('composer.lock', $changed_files_list)) {
      $collection->addCode(
        function () use ($changed_files) {
          return $this->invokeCommand('tests:composer:validate');
        }
      );
    }

    $result = $collection
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();

    if ($result->wasSuccessful()) {
      $this->say("<info>Your local code has passed git pre-commit validation.</info>");
    }

    return $result;
  }
public function preCommitHook ( $ changed_files ) { $ collection = $ this -> collectionBuilder ( ) ; $ collection -> setProgressIndicator ( NULL ) ; $ collection -> addCode ( function ( ) use ( $ changed_files ) { return $ this -> invokeCommands ( [ 'tests:phpcs:sniff:files' => [ 'file_list' => $ changed_files ] , 'tests:twig:lint:files' => [ 'file_list' => $ changed_files ] , 'tests:yaml:lint:files' => [ 'file_list' => $ changed_files ] , ] ) ; } ) ; $ changed_files_list = explode ( "\n" , $ changed_files ) ; if ( in_array ( 'composer.json' , $ changed_files_list ) || in_array ( 'composer.lock' , $ changed_files_list ) ) { $ collection -> addCode ( function ( ) use ( $ changed_files ) { return $ this -> invokeCommand ( 'tests:composer:validate' ) ; } ) ; } $ result = $ collection -> setVerbosityThreshold ( VerbosityThresholdInterface :: VERBOSITY_VERBOSE ) -> run ( ) ; if ( $ result -> wasSuccessful ( ) ) { $ this -> say ( "<info>Your local code has passed git pre-commit validation.</info>" ) ; } return $ result ; }
Validates staged files.

@command internal:git-hook:execute:pre-commit
@aliases git:pre-commit
@hidden

@param string $changed_files
A list of staged files, separated by \n.

@return \Robo\Result
Validates staged files .