Ejemplo n.º 1
0
 /**
  * Set up test model
  */
 public static function setUpBeforeClass()
 {
     //init config
     Config::initInstance(['file' => PROJECT_ROOT . '/config/root.xml']);
     Config::setSrcRootDir(PROJECT_ROOT);
     Config::mergeExtraConfig();
 }
Ejemplo n.º 2
0
 /**
  * Set up test model
  */
 public static function setUpBeforeClass()
 {
     Config::initInstance(['file' => PROJECT_ROOT . '/config/root.xml']);
     Config::setSrcRootDir(PROJECT_ROOT);
     $vcsAdapter = self::getVcsAdapterMock();
     /** @var PreCommit $preCommit */
     $preCommit = Processor::factory('pre-commit', $vcsAdapter);
     $preCommit->setCodePath(self::getCodePath())->setFiles([self::$classTest]);
     $preCommit->process();
     self::$model = $preCommit;
 }
Ejemplo n.º 3
0
 /**
  * Set up test model
  */
 public static function setUpBeforeClass()
 {
     //init config object
     Config::initInstance(['file' => PROJECT_ROOT . '/config/root.xml']);
     Config::setSrcRootDir(PROJECT_ROOT);
     Config::mergeExtraConfig();
     $vcsAdapter = self::getVcsAdapterMock();
     /** @var Processor\PreCommit $processor */
     $processor = Processor::factory('pre-commit', ['vcs' => $vcsAdapter]);
     $processor->setCodePath(PROJECT_ROOT)->setFiles([self::$fileTest]);
     $processor->process();
     self::$model = $processor;
 }
Ejemplo n.º 4
0
 /**
  * Get base config (without project files)
  *
  * @return Config
  */
 public function getConfigBase()
 {
     static $config;
     if (null === $config) {
         //TODO Make single load
         $config = Config::initInstance(['file' => $this->commithookDir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'root.xml']);
         if (!Config::loadCache()) {
             Config::mergeExtraConfig();
         }
         $config = Config::getInstance();
     }
     return $config;
 }
Ejemplo n.º 5
0
<?php

// @codingStandardsIgnoreFile
/**
 * @license https://raw.githubusercontent.com/andkirby/commithook/master/LICENSE.md
 */
define('PROJECT_ROOT', realpath(__DIR__ . '/../..'));
!defined('GIT_BIN') && define('GIT_BIN', 'git');
/** @var Composer\Autoload\ClassLoader $autoloader */
require realpath(__DIR__ . '/../../..') . '/bin/autoload-init.php';
//load config
try {
    \PreCommit\Config::setSrcRootDir(__DIR__ . '/../../');
    $config = \PreCommit\Config::initInstance(array('file' => __DIR__ . '/root.xml'));
    \PreCommit\Config::mergeExtraConfig();
} catch (\Exception $e) {
    echo $e;
    exit(1);
}
Ejemplo n.º 6
0
*/
!defined('COMMIT_HOOKS_ROOT') && define('COMMIT_HOOKS_ROOT', realpath(__DIR__ . '/..'));
!defined('TEST_MODE') && define('TEST_MODE', false);
!defined('GIT_BIN') && define('GIT_BIN', 'git');
set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), COMMIT_HOOKS_ROOT . '/src/lib')));
//init autoloader
require_once __DIR__ . '/../bin/autoload-init.php';
//Get VCS type
$vcs = isset($vcs) ? $vcs : 'git';
//Get VCS files
$vcsFiles = isset($vcsFiles) ? $vcsFiles : null;
//load config
if (!isset($rootConfigFile)) {
    $rootConfigFile = COMMIT_HOOKS_ROOT . '/src/config/root.xml';
}
$config = \PreCommit\Config::initInstance(array('file' => $rootConfigFile));
//prepare head block for output
$output = array();
$output['head'] = 'PHP CommitHooks v' . $config->getNode('version');
$output['head'] .= PHP_EOL;
$output['head'] .= 'Please report all hook bugs to the GitHub project.';
$output['head'] .= PHP_EOL;
$output['head'] .= 'http://github.com/andkirby/commithook';
$output['head'] .= PHP_EOL . PHP_EOL;
//Process hook name
$supportedHooks = $config->getNodeArray('supported_hooks');
$supportedHooks = $supportedHooks['hook'];
if (empty($hookFile)) {
    //try to get hook name from backtrace
    $backtrace = debug_backtrace();
    if (isset($backtrace[0]['file'])) {