diff --git a/scripts/pre-commit.php b/scripts/pre-commit.php index b41074785d..ff1962b99a 100755 --- a/scripts/pre-commit.php +++ b/scripts/pre-commit.php @@ -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'); }