31
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-06-03 22:20:48 +00:00

Added configuration support for CI-Server. Now it is possible to switch between methods of applying patches.

This commit is contained in:
datsepp 2019-09-11 14:57:35 +02:00
parent b5bd81143e
commit 13bc747b71
6 changed files with 138 additions and 78 deletions

View File

@ -72,10 +72,12 @@ abstract class Helper
*/
public static function initializeCISettings()
{
$params = ComponentHelper::getParams('com_patchtester');
$options = new Registry;
// Set CI server address for the request
$options->set('server.url', 'https://joomla-dev.lukaskimpel.com');
$options->set('server.url', $params->get('ci_server', 'https://ci.joomla.org'));
// Set name of the zip archive
$options->set('zip.name', 'build.zip');

View File

@ -156,7 +156,7 @@ class PullModel extends AbstractModel
$params = ComponentHelper::getParams('com_patchtester');
// Decide based on repository settings whether patch will be applied through Github or CIServer
if ($params->get('repo', 'joomla-cms') === 'joomla-cms'
if ((bool) $params->get('ci_switch', 1) && $params->get('repo', 'joomla-cms') === 'joomla-cms'
&& $params->get('org', 'joomla') === 'joomla')
{
return $this->applyWithCIServer($id);
@ -249,11 +249,14 @@ class PullModel extends AbstractModel
File::delete($zipPath);
// get files from deleted_logs
$deletedFiles = file($delLogPath);
$deletedFiles = (file($delLogPath) ? file($delLogPath) : []);
$deletedFiles = array_map('trim', $deletedFiles);
// remove deleted_logs to avoid get listing afterwards
File::delete($delLogPath);
if(file_exists($delLogPath))
{
// remove deleted_logs to avoid get listing afterwards
File::delete($delLogPath);
}
// retrieve all files and merge them into one array
$files = Folder::files($tempPath, null, true, true);
@ -289,20 +292,21 @@ class PullModel extends AbstractModel
File::move(JPATH_ROOT . "/$file", "$backupsPath/$file");
}
// Create directories if they don't exist until file
if (!file_exists(JPATH_ROOT . "/$filePath") || !is_dir(JPATH_ROOT . "/$filePath"))
{
Folder::create(JPATH_ROOT . "/$filePath");
}
if (file_exists("$tempPath/$file"))
{
// Create directories if they don't exist until file
if (!file_exists(JPATH_ROOT . "/$filePath") || !is_dir(JPATH_ROOT . "/$filePath"))
{
Folder::create(JPATH_ROOT . "/$filePath");
}
File::copy("$tempPath/$file", JPATH_ROOT . "/$file");
}
}
catch(\RuntimeException $e)
{
Folder::delete($tempPath);
Folder::move($backupsPath, $backupsPath . "_failed");
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_FAILED_APPLYING_PATCH', $file, $e->getMessage()));
}
@ -576,7 +580,7 @@ class PullModel extends AbstractModel
$params = ComponentHelper::getParams('com_patchtester');
// Decide based on repository settings whether patch will be applied through Github or CIServer
if ($params->get('repo', 'joomla-cms') === 'joomla-cms'
if ((bool) $params->get('ci_switch', 1) && $params->get('repo', 'joomla-cms') === 'joomla-cms'
&& $params->get('org', 'joomla') === 'joomla')
{
return $this->revertWithCIServer($id);

View File

@ -2,63 +2,65 @@
<config>
<fieldset
name="repositories"
label="COM_PATCHTESTER_FIELDSET_REPOSITORIES_LABEL"
description="COM_PATCHTESTER_FIELDSET_REPOSITORIES_DESC"
>
name="repositories"
label="COM_PATCHTESTER_FIELDSET_REPOSITORIES_LABEL"
description="COM_PATCHTESTER_FIELDSET_REPOSITORIES_DESC"
>
<field
name="repository"
type="list"
label="COM_PATCHTESTER_FIELD_REPOSITORY_LABEL"
description="COM_PATCHTESTER_FIELD_REPOSITORY_DESC"
default="joomla:joomla-cms"
onchange="if (jQuery(this).val() != 'custom') { var parts = jQuery(this).val().split(':'); } else { var parts = ['', '']; } document.getElementById('jform_org').value = parts[0]; document.getElementById('jform_repo').value = parts[1];"
>
name="repository"
type="list"
label="COM_PATCHTESTER_FIELD_REPOSITORY_LABEL"
description="COM_PATCHTESTER_FIELD_REPOSITORY_DESC"
default="joomla:joomla-cms"
onchange="if (jQuery(this).val() != 'custom') { var parts = jQuery(this).val().split(':'); } else { var parts = ['', '']; } document.getElementById('jform_org').value = parts[0]; document.getElementById('jform_repo').value = parts[1];"
>
<option value="joomla:joomla-cms">COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_JOOMLA_CMS</option>
<option value="joomla-extensions:patchtester">COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_PATCHTESTER</option>
<option value="joomla-extensions:install-from-web-client">COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_INSTALL_FROM_WEB</option>
<option value="joomla-extensions:install-from-web-client">
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_INSTALL_FROM_WEB
</option>
<option value="joomla-extensions:weblinks">COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_WEBLINKS</option>
<option value="custom">COM_PATCHTESTER_FIELD_REPOSITORY_CUSTOM</option>
</field>
<field
name="org"
type="text"
label="COM_PATCHTESTER_FIELD_ORG_LABEL"
description="COM_PATCHTESTER_FIELD_ORG_DESC"
default="joomla"
id="org"
showon="repository:custom"
name="org"
type="text"
label="COM_PATCHTESTER_FIELD_ORG_LABEL"
description="COM_PATCHTESTER_FIELD_ORG_DESC"
default="joomla"
id="org"
showon="repository:custom"
/>
<field
name="repo"
type="text"
label="COM_PATCHTESTER_FIELD_REPO_LABEL"
description="COM_PATCHTESTER_FIELD_REPO_DESC"
default="joomla-cms"
id="repo"
showon="repository:custom"
name="repo"
type="text"
label="COM_PATCHTESTER_FIELD_REPO_LABEL"
description="COM_PATCHTESTER_FIELD_REPO_DESC"
default="joomla-cms"
id="repo"
showon="repository:custom"
/>
</fieldset>
<fieldset
name="authentication"
label="COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL"
description="COM_PATCHTESTER_FIELDSET_AUTHENTICATION_DESC"
>
name="authentication"
label="COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL"
description="COM_PATCHTESTER_FIELDSET_AUTHENTICATION_DESC"
>
<field
name="gh_auth"
type="list"
label="COM_PATCHTESTER_FIELD_GH_AUTH_LABEL"
description="COM_PATCHTESTER_FIELD_GH_AUTH_DESC"
default=""
onchange="jQuery('#jform_gh_user, #jform_gh_password, #jform_gh_token').val('');"
name="gh_auth"
type="list"
label="COM_PATCHTESTER_FIELD_GH_AUTH_LABEL"
description="COM_PATCHTESTER_FIELD_GH_AUTH_DESC"
default=""
onchange="jQuery('#jform_gh_user, #jform_gh_password, #jform_gh_token').val('');"
>
>
<option value="">JNONE</option>
<option value="credentials">COM_PATCHTESTER_FIELD_GH_AUTH_OPTION_CREDENTIALS</option>
<option value="token">COM_PATCHTESTER_FIELD_GH_AUTH_OPTION_TOKEN</option>
@ -66,49 +68,77 @@
<!-- Note: Default username is a space to avoid browser autocomplete. -->
<field
name="gh_user"
type="text"
label="COM_PATCHTESTER_FIELD_GH_USER_LABEL"
description="COM_PATCHTESTER_FIELD_GH_USER_DESC"
autocomplete="off"
default=" "
showon="gh_auth:credentials"
name="gh_user"
type="text"
label="COM_PATCHTESTER_FIELD_GH_USER_LABEL"
description="COM_PATCHTESTER_FIELD_GH_USER_DESC"
autocomplete="off"
default=" "
showon="gh_auth:credentials"
/>
<field
name="gh_password"
type="password"
label="COM_PATCHTESTER_FIELD_GH_PASSWORD_LABEL"
description="COM_PATCHTESTER_FIELD_GH_PASSWORD_DESC"
autocomplete="off"
default=""
showon="gh_auth:credentials"
name="gh_password"
type="password"
label="COM_PATCHTESTER_FIELD_GH_PASSWORD_LABEL"
description="COM_PATCHTESTER_FIELD_GH_PASSWORD_DESC"
autocomplete="off"
default=""
showon="gh_auth:credentials"
/>
<field
name="gh_token"
type="text"
label="COM_PATCHTESTER_FIELD_GH_TOKEN_LABEL"
description="COM_PATCHTESTER_FIELD_GH_TOKEN_DESC"
showon="gh_auth:token"
name="gh_token"
type="text"
label="COM_PATCHTESTER_FIELD_GH_TOKEN_LABEL"
description="COM_PATCHTESTER_FIELD_GH_TOKEN_DESC"
showon="gh_auth:token"
/>
</fieldset>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
name="ci_settings"
label="COM_PATCHTESTER_FIELDSET_CI_SETTINGS"
description="COM_PATCHTESTER_FIELDSET_CI_SETTINGS_DESC"
>
<field
name="rules"
type="rules"
name="ci_server"
type="text"
label="COM_PATCHTESTER_FIELD_CI_SERVER_NAME"
description="COM_PATCHTESTER_FIELD_CI_SERVER_NAME_DESC"
autocomplete="off"
default="https://ci.joomla.org"
/>
<field
name="ci_switch"
type="list"
label="COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH"
description="COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_DESC"
default="1"
>
<option value="1">COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_OPTION_ON</option>
<option value="0">COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_OPTION_OFF</option>
</field>
</fieldset>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
component="com_patchtester"
filter="rules"
validate="rules"
section="component"
description="JCONFIG_PERMISSIONS_DESC"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
component="com_patchtester"
filter="rules"
validate="rules"
section="component"
/>
</fieldset>

View File

@ -59,10 +59,18 @@ COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_PATCHTESTER = "Joomla! Patch-Tester Komp
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_INSTALL_FROM_WEB = "Joomla! Webkataloginstallations-Plugin"
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_WEBLINKS = "Joomla! Weblinks-Paket"
COM_PATCHTESTER_FIELD_REPOSITORY_CUSTOM = "Benutzerdefiniert"
COM_PATCHTESTER_FIELD_CI_SERVER_NAME="CI Server Adresse"
COM_PATCHTESTER_FIELD_CI_SERVER_NAME_DESC="Server Adresse für das Herunterladen kompilierter Patches."
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH="Switch CI Integration"
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_DESC="Schaltet die CI Integration an oder aus."
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_OPTION_ON="An"
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_OPTION_OFF="Aus"
COM_PATCHTESTER_FIELDSET_REPOSITORIES_DESC = "Konfigurationswerte für GitHub Repository"
COM_PATCHTESTER_FIELDSET_REPOSITORIES_LABEL = "GitHub Repository"
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_DESC = "Konfigurationswerte für GitHub Authentifizierung"
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL = "GitHub Authentifizierung"
COM_PATCHTESTER_FIELDSET_CI_SETTINGS="CI Server Einstellungen"
COM_PATCHTESTER_FIELDSET_CI_SETTINGS_DESC="Konfigurationswerte für CI Server Patching"
COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S = "Die zu löschende Datei existiert nicht: %s"
COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S = "Die zu ändernde Datei existiert nicht: %s"
COM_PATCHTESTER_FILTER_APPLIED_PATCHES = "Angewendete Patches filtern"

View File

@ -59,10 +59,18 @@ COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_PATCHTESTER="Joomla! Patch Tester Compon
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_INSTALL_FROM_WEB="Joomla! Install From Web Plugin"
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_WEBLINKS="Joomla! Weblinks Package"
COM_PATCHTESTER_FIELD_REPOSITORY_CUSTOM="Custom"
COM_PATCHTESTER_FIELD_CI_SERVER_NAME="CI Server Address"
COM_PATCHTESTER_FIELD_CI_SERVER_NAME_DESC="Server address for obtaining compiled patches."
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH="Switch CI Integration"
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_DESC="Turn CI integration on or off."
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_OPTION_ON="On"
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_OPTION_OFF="Off"
COM_PATCHTESTER_FIELDSET_REPOSITORIES_DESC="Configuration Values for GitHub Repository"
COM_PATCHTESTER_FIELDSET_REPOSITORIES_LABEL="GitHub Repository"
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_DESC="Configuration Values for GitHub Authentication"
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL="GitHub Authentication"
COM_PATCHTESTER_FIELDSET_CI_SETTINGS="CI Server Settings"
COM_PATCHTESTER_FIELDSET_CI_SETTINGS_DESC="Configuration Values for CI Server Patching"
COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S="The file marked for deletion does not exist: %s"
COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S="The file marked for modification does not exist: %s"
COM_PATCHTESTER_FILTER_APPLIED_PATCHES="Filter Applied Patches"

View File

@ -59,10 +59,18 @@ COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_PATCHTESTER="Joomla! Patch Tester Compon
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_INSTALL_FROM_WEB="Joomla! Install From Web Plugin"
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_WEBLINKS="Joomla! Weblinks Package"
COM_PATCHTESTER_FIELD_REPOSITORY_CUSTOM="Custom"
COM_PATCHTESTER_FIELD_CI_SERVER_NAME="CI Server Address"
COM_PATCHTESTER_FIELD_CI_SERVER_NAME_DESC="Server address for obtaining compiled patches."
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH="Switch CI Integration"
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_DESC="Turn CI integration on or off."
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_OPTION_ON="On"
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH_OPTION_OFF="Off"
COM_PATCHTESTER_FIELDSET_REPOSITORIES_DESC="Configuration Values for GitHub Repository"
COM_PATCHTESTER_FIELDSET_REPOSITORIES_LABEL="GitHub Repository"
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_DESC="Configuration Values for GitHub Authentication"
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL="GitHub Authentication"
COM_PATCHTESTER_FIELDSET_CI_SETTINGS="CI Server Settings"
COM_PATCHTESTER_FIELDSET_CI_SETTINGS_DESC="Configuration Values for CI Server Patching"
COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S="The file marked for deletion does not exist: %s"
COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S="The file marked for modification does not exist: %s"
COM_PATCHTESTER_FILTER_APPLIED_PATCHES="Filter Applied Patches"