forked from octobercms/october
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wip/image-resizing' of github.com:octobercms/october in…
…to wip/image-resizing
- Loading branch information
Showing
13 changed files
with
250 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
if (empty($argv[1])) { | ||
echo 'You must provide a base branch to check this PR against.'; | ||
echo "\n"; | ||
exit(1); | ||
} | ||
|
||
// Get a changelist of files from Git for this PR. | ||
$fileList = shell_exec('git diff --name-only --diff-filter=ACMR origin/' . $argv[1] . ' HEAD'); | ||
$files = array_filter(explode("\n", $fileList)); | ||
|
||
foreach ($files as &$file) { | ||
if (strpos($file, ' ') !== false) { | ||
$file = str_replace(' ', '\\ ', $file); | ||
} | ||
} | ||
|
||
// Run all changed files through the PHPCS code sniffer and generate a CSV report | ||
$csv = shell_exec('phpcs --colors -nq --report="csv" --extensions="php" ' . implode(' ', $files)); | ||
$lines = array_map(function ($row) { | ||
return array_map(function ($column) { | ||
return trim($column, '"'); | ||
}, explode(',', $row)); | ||
}, array_filter(explode("\n", $csv))); | ||
|
||
// Remove header row | ||
array_shift($lines); | ||
|
||
if (!count($lines)) { | ||
echo "\e[0;32mFound no issues with code quality.\e[0m"; | ||
echo "\n"; | ||
exit(0); | ||
} else { | ||
// Group errors by file | ||
$files = []; | ||
|
||
foreach ($lines as $line) { | ||
$filename = str_replace(dirname(dirname(dirname(__DIR__))), '', $line[0]); | ||
|
||
if (empty($files[$filename])) { | ||
$files[$filename] = []; | ||
} | ||
|
||
$files[$filename][] = [ | ||
'warning' => ($line[3] === 'warning'), | ||
'message' => $line[4], | ||
'line' => $line[1], | ||
]; | ||
} | ||
|
||
// Render report | ||
echo "\e[0;31mFound " | ||
. ((count($lines) === 1) | ||
? '1 issue' | ||
: count($lines) . ' issues') | ||
. " with code quality.\e[0m"; | ||
echo "\n"; | ||
|
||
foreach ($files as $file => $errors) { | ||
echo "\n"; | ||
echo "\e[1;37m" . str_replace('"', '', $file) . "\e[0m"; | ||
echo "\n\n"; | ||
|
||
foreach ($errors as $error) { | ||
echo "\e[2m" . str_pad(' L' . $error['line'], 7) . " | \e[0m"; | ||
if ($error['warning'] === false) { | ||
echo "\e[0;31mERR:\e[0m "; | ||
} else { | ||
echo "\e[1;33mWARN:\e[0m "; | ||
} | ||
echo $error['message']; | ||
echo "\n"; | ||
} | ||
} | ||
exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
if (empty($argv[1])) { | ||
echo 'You must provide a commit SHA to check.'; | ||
echo "\n"; | ||
exit(1); | ||
} | ||
|
||
// Get a changelist of files from Git for this push. | ||
$fileList = shell_exec('git show --name-only --pretty="" --diff-filter=ACMR ' . $argv[1]); | ||
$files = array_filter(explode("\n", $fileList)); | ||
|
||
foreach ($files as &$file) { | ||
if (strpos($file, ' ') !== false) { | ||
$file = str_replace(' ', '\\ ', $file); | ||
} | ||
} | ||
|
||
// Run all changed files through the PHPCS code sniffer and generate a CSV report | ||
$csv = shell_exec('phpcs --colors -nq --report="csv" --extensions="php" ' . implode(' ', $files)); | ||
$lines = array_map(function ($row) { | ||
return array_map(function ($column) { | ||
return trim($column, '"'); | ||
}, explode(',', $row)); | ||
}, array_filter(explode("\n", $csv))); | ||
|
||
// Remove header row | ||
array_shift($lines); | ||
|
||
if (!count($lines)) { | ||
echo "\e[0;32mFound no issues with code quality.\e[0m"; | ||
echo "\n"; | ||
exit(0); | ||
} else { | ||
// Group errors by file | ||
$files = []; | ||
|
||
foreach ($lines as $line) { | ||
$filename = str_replace(dirname(dirname(dirname(__DIR__))), '', $line[0]); | ||
|
||
if (empty($files[$filename])) { | ||
$files[$filename] = []; | ||
} | ||
|
||
$files[$filename][] = [ | ||
'warning' => ($line[3] === 'warning'), | ||
'message' => $line[4], | ||
'line' => $line[1], | ||
]; | ||
} | ||
|
||
// Render report | ||
echo "\e[0;31mFound " | ||
. ((count($lines) === 1) | ||
? '1 issue' | ||
: count($lines) . ' issues') | ||
. " with code quality.\e[0m"; | ||
echo "\n"; | ||
|
||
foreach ($files as $file => $errors) { | ||
echo "\n"; | ||
echo "\e[1;37m" . str_replace('"', '', $file) . "\e[0m"; | ||
echo "\n\n"; | ||
|
||
foreach ($errors as $error) { | ||
echo "\e[2m" . str_pad(' L' . $error['line'], 7) . " | \e[0m"; | ||
if ($error['warning'] === false) { | ||
echo "\e[0;31mERR:\e[0m "; | ||
} else { | ||
echo "\e[1;33mWARN:\e[0m "; | ||
} | ||
echo $error['message']; | ||
echo "\n"; | ||
} | ||
} | ||
exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.