photo-front/documentation/hooks/pre-commit
2012-01-02 18:55:13 -08:00

20 lines
689 B
PHP
Executable file

#!/usr/bin/php
<?php
/*
* Git pre-commit hook
* To use this just symlink it to .git/hooks/pre-commit or copy it there and make modifications as needed.
*/
$baseDir = dirname(dirname(dirname(__FILE__)));
chdir($baseDir);
printf("%sGit pre-commit hook %1\$s", PHP_EOL);
$projectName = basename(getcwd());
exec('phpunit src/tests/', $output, $returnCode); // Assuming cwd here
if ($returnCode !== 0) {
$minimalTestSummary = array_pop($output);
printf("Test suite for %s failed: ", $projectName);
echo implode("\n", $output);
printf("( %s ) %s%2\$s", $minimalTestSummary, PHP_EOL);
exit(1);
}
printf("All tests for %s passed.%s%2\$s", $projectName, PHP_EOL);
exit(0);