diff --git a/pre-commit b/pre-commit index c94bff5..e7bc63a 100755 --- a/pre-commit +++ b/pre-commit @@ -77,14 +77,24 @@ class CodeQualityTool extends Application $output = array(); $rc = 0; - exec('git rev-parse --verify HEAD 2> /dev/null', $output, $rc); + exec('git rev-parse --verify HEAD 2> ' . ( DIRECTORY_SEPARATOR == '/' ? '/dev/null' : 'NUL' ), $output, $rc); $against = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; if ($rc == 0) { $against = 'HEAD'; } - exec("git diff-index --cached --name-status $against | egrep '^(A|M)' | awk '{print $2;}'", $output); + // exec("git diff-index --cached --name-status $against | egrep '^(A|M)' | awk '{print $2;}'", $output); + exec("git diff-index --cached --name-status $against ", $output); + if (count($output) > 0) { + foreach ($output as $k=>$v) { + if (preg_match("#[A|M]\s(.+?)$#",$v,$a)) { + $output[$k] = $a[1]; + } else { + unset($output[$k]); + } + } + } return $output; }