From 1def6897a69477666eec53c4e2e9b50581124597 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 28 Dec 2018 20:05:52 -0600 Subject: [PATCH] allow pre-commit.php to work without changes (#9597) * allow pre-commit.php to work without changes * make it actually work :D --- scripts/pre-commit.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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'); }