Even more codestyle
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
This commit is contained in:
parent
aeb58bebef
commit
d167f62f73
|
@ -525,7 +525,9 @@ class PullModel extends BaseDatabaseModel
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
|
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
|
||||||
$exception->getMessage()
|
$exception->getMessage()
|
||||||
), $exception->getCode(), $exception
|
),
|
||||||
|
$exception->getCode(),
|
||||||
|
$exception
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,11 +558,7 @@ class PullModel extends BaseDatabaseModel
|
||||||
case 'modified':
|
case 'modified':
|
||||||
case 'renamed':
|
case 'renamed':
|
||||||
// If the backup file already exists, we can't apply the patch
|
// If the backup file already exists, we can't apply the patch
|
||||||
if (file_exists(
|
if (file_exists(JPATH_COMPONENT . '/backups/' . md5($file->filename) . '.txt')) {
|
||||||
JPATH_COMPONENT . '/backups/' . md5($file->filename)
|
|
||||||
. '.txt'
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_CONFLICT_S',
|
'COM_PATCHTESTER_CONFLICT_S',
|
||||||
|
@ -569,11 +567,9 @@ class PullModel extends BaseDatabaseModel
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($file->action === 'modified'
|
if (
|
||||||
&& !file_exists(
|
$file->action === 'modified'
|
||||||
JPATH_ROOT . '/' . $file->filename
|
&& !file_exists(JPATH_ROOT . '/' . $file->filename)) {
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S',
|
'COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S',
|
||||||
|
@ -611,7 +607,9 @@ class PullModel extends BaseDatabaseModel
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
|
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
|
||||||
$exception->getMessage()
|
$exception->getMessage()
|
||||||
), $exception->getCode(), $exception
|
),
|
||||||
|
$exception->getCode(),
|
||||||
|
$exception
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,16 +622,13 @@ class PullModel extends BaseDatabaseModel
|
||||||
// We only create a backup if the file already exists
|
// We only create a backup if the file already exists
|
||||||
if (
|
if (
|
||||||
$file->action === 'deleted'
|
$file->action === 'deleted'
|
||||||
|| (file_exists(JPATH_ROOT . '/' . $file->filename)
|
|| (file_exists(JPATH_ROOT . '/' . $file->filename) && $file->action === 'modified')
|
||||||
&& $file->action === 'modified')
|
|| (file_exists(JPATH_ROOT . '/' . $file->originalFile) && $file->action === 'renamed')
|
||||||
|| (file_exists(JPATH_ROOT . '/' . $file->originalFile)
|
|
||||||
&& $file->action === 'renamed')
|
|
||||||
) {
|
) {
|
||||||
$filename = $file->action === 'renamed' ? $file->originalFile
|
$filename = $file->action === 'renamed' ? $file->originalFile : $file->filename;
|
||||||
: $file->filename;
|
|
||||||
$src = JPATH_ROOT . '/' . $filename;
|
$src = JPATH_ROOT . '/' . $filename;
|
||||||
$dest = JPATH_COMPONENT . '/backups/' . md5($filename)
|
$dest = JPATH_COMPONENT . '/backups/' . md5($filename) . '.txt';
|
||||||
. '.txt';
|
|
||||||
if (!File::copy(Path::clean($src), $dest)) {
|
if (!File::copy(Path::clean($src), $dest)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
|
@ -648,11 +643,7 @@ class PullModel extends BaseDatabaseModel
|
||||||
switch ($file->action) {
|
switch ($file->action) {
|
||||||
case 'modified':
|
case 'modified':
|
||||||
case 'added':
|
case 'added':
|
||||||
if (!File::write(
|
if (!File::write(Path::clean(JPATH_ROOT . '/' . $file->filename), $file->body)) {
|
||||||
Path::clean(JPATH_ROOT . '/' . $file->filename),
|
|
||||||
$file->body
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_ERROR_CANNOT_WRITE_FILE',
|
'COM_PATCHTESTER_ERROR_CANNOT_WRITE_FILE',
|
||||||
|
@ -664,10 +655,7 @@ class PullModel extends BaseDatabaseModel
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'deleted':
|
case 'deleted':
|
||||||
if (!File::delete(
|
if (!File::delete(Path::clean(JPATH_ROOT . '/' . $file->filename))) {
|
||||||
Path::clean(JPATH_ROOT . '/' . $file->filename)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE',
|
'COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE',
|
||||||
|
@ -679,10 +667,7 @@ class PullModel extends BaseDatabaseModel
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'renamed':
|
case 'renamed':
|
||||||
if (!File::delete(
|
if (!File::delete(Path::clean(JPATH_ROOT . '/' . $file->originalFile))) {
|
||||||
Path::clean(JPATH_ROOT . '/' . $file->originalFile)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE',
|
'COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE',
|
||||||
|
@ -691,11 +676,7 @@ class PullModel extends BaseDatabaseModel
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!File::write(
|
if (!File::write(Path::clean(JPATH_ROOT . '/' . $file->filename), $file->body)) {
|
||||||
Path::clean(JPATH_ROOT . '/' . $file->filename),
|
|
||||||
$file->body
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
Text::sprintf(
|
Text::sprintf(
|
||||||
'COM_PATCHTESTER_ERROR_CANNOT_WRITE_FILE',
|
'COM_PATCHTESTER_ERROR_CANNOT_WRITE_FILE',
|
||||||
|
@ -741,10 +722,7 @@ class PullModel extends BaseDatabaseModel
|
||||||
$id,
|
$id,
|
||||||
$page
|
$page
|
||||||
);
|
);
|
||||||
$files = array_merge(
|
$files = array_merge($files, json_decode($filesResponse->getBody(), false));
|
||||||
$files,
|
|
||||||
json_decode($filesResponse->getBody(), false)
|
|
||||||
);
|
|
||||||
$lastPage = 1;
|
$lastPage = 1;
|
||||||
$headers = $filesResponse->getHeaders();
|
$headers = $filesResponse->getHeaders();
|
||||||
|
|
||||||
|
@ -780,11 +758,11 @@ class PullModel extends BaseDatabaseModel
|
||||||
*/
|
*/
|
||||||
private function parseFileList(array $files): array
|
private function parseFileList(array $files): array
|
||||||
{
|
{
|
||||||
$parsedFiles = array();
|
$parsedFiles = [];
|
||||||
/*
|
/*
|
||||||
* Check if the patch tester is running in a development environment
|
* Check if the patch tester is running in a development environment
|
||||||
* If we are not in development, we'll need to check the exclusion lists
|
* If we are not in development, we'll need to check the exclusion lists
|
||||||
*/
|
*/
|
||||||
$isDev = file_exists(JPATH_INSTALLATION . '/index.php');
|
$isDev = file_exists(JPATH_INSTALLATION . '/index.php');
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (!$isDev) {
|
if (!$isDev) {
|
||||||
|
|
Loading…
Reference in New Issue