allow pre-commit.php to work without changes (#9597)

* allow pre-commit.php to work without changes

* make it actually work :D
This commit is contained in:
Tony Murray
2018-12-28 20:05:52 -06:00
committed by GitHub
parent de7ce7c757
commit 1def6897a6

View File

@@ -13,7 +13,7 @@ if (getenv('FILES')) {
$changed_files = exec("git diff --diff-filter=d --name-only master | tr '\n' ' '|sed 's/,*$//g'");
}
$changed_files = explode(' ', $changed_files);
$changed_files = $changed_files ? explode(' ', $changed_files) : [];
$map = [
'docs' => 0,
@@ -122,13 +122,13 @@ if (check_opt($options, 'db')) {
}
// No php files, skip the php checks.
if ($map['php'] === 0) {
if (!empty($changed_files) && $map['php'] === 0) {
putenv('SKIP_LINT_CHECK=1');
putenv('SKIP_STYLE_CHECK=1');
}
// If we have no php files and no OS' found then also skip unit checks.
if ($map['php'] === 0 && empty($map['os']) && !$os) {
if (!empty($changed_files) && $map['php'] === 0 && empty($map['os']) && !$os) {
putenv('SKIP_UNIT_CHECK=1');
}