Skip to content

Commit f96dfdb

Browse files
authored
[4.0] Patch tester enhancement for joomla4 (pre-compiled diff) (#227)
[4.0] Patch tester enhancement for joomla4 (pre-compiled diff)
2 parents 4c1c271 + 8286b48 commit f96dfdb

File tree

23 files changed

+970
-285
lines changed

23 files changed

+970
-285
lines changed

administrator/components/com_patchtester/PatchTester/Controller/ResetController.php

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,43 +42,61 @@ public function execute()
4242
$testsModel = new TestsModel(null, Factory::getDbo());
4343

4444
// Check the applied patches in the database first
45-
$appliedPatches = $testsModel->getAppliedPatches();
45+
$appliedPatches = $pullModel->getPatchesDividedInProcs();
4646

47-
if (count($appliedPatches))
47+
if (count($appliedPatches['git']))
4848
{
4949
$revertErrored = false;
5050

5151
// Let's try to cleanly revert all applied patches
52-
foreach ($appliedPatches as $patch)
52+
foreach ($appliedPatches['git'] as $patch)
5353
{
5454
try
5555
{
56-
$pullModel->revert($patch->id);
56+
$pullModel->revertWithGitHub($patch->id);
5757
}
5858
catch (\RuntimeException $e)
5959
{
6060
$revertErrored = true;
6161
}
6262
}
63+
}
6364

64-
// If we errored out reverting patches, we'll need to truncate the table
65-
if ($revertErrored)
65+
if (count($appliedPatches['ci']))
66+
{
67+
$revertErrored = false;
68+
69+
// Let's try to cleanly revert all applied patches with ci
70+
foreach ($appliedPatches['ci'] as $patch)
6671
{
6772
try
6873
{
69-
$testsModel->truncateTable();
74+
$pullModel->revertWithCIServer($patch->insert_id);
7075
}
7176
catch (\RuntimeException $e)
7277
{
73-
$hasErrors = true;
74-
75-
$this->getApplication()->enqueueMessage(
76-
Text::sprintf('COM_PATCHTESTER_ERROR_TRUNCATING_PULLS_TABLE', $e->getMessage()), 'error'
77-
);
78+
$revertErrored = true;
7879
}
7980
}
8081
}
8182

83+
// If we errored out reverting patches, we'll need to truncate the table
84+
if ($revertErrored)
85+
{
86+
try
87+
{
88+
$testsModel->truncateTable();
89+
}
90+
catch (\RuntimeException $e)
91+
{
92+
$hasErrors = true;
93+
94+
$this->getApplication()->enqueueMessage(
95+
Text::sprintf('COM_PATCHTESTER_ERROR_TRUNCATING_PULLS_TABLE', $e->getMessage()), 'error'
96+
);
97+
}
98+
}
99+
82100
// Now truncate the pulls table
83101
try
84102
{

administrator/components/com_patchtester/PatchTester/Helper.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,34 @@ public static function initializeGithub()
6262

6363
return new GitHub($options);
6464
}
65+
66+
/**
67+
* Initializes the CI Settings
68+
*
69+
* @return Registry
70+
*
71+
* @since 3.0
72+
*/
73+
public static function initializeCISettings()
74+
{
75+
$params = ComponentHelper::getParams('com_patchtester');
76+
77+
$options = new Registry;
78+
79+
// Set CI server address for the request
80+
$options->set('server.url', $params->get('ci_server', 'https://ci.joomla.org:444'));
81+
82+
// Set name of the zip archive
83+
$options->set('zip.name', 'build.zip');
84+
$options->set('zip.log.name', 'deleted_files.log');
85+
86+
// Set temp archive for extracting and downloading files
87+
$options->set('folder.temp', Factory::getConfig()->get('tmp_path'));
88+
$options->set('folder.backups', JPATH_COMPONENT . '/backups');
89+
90+
// Set full url for addressing the file
91+
$options->set('zip.url', $options->get('server.url') . '/artifacts/joomla/joomla-cms/4.0-dev/%s/patchtester/' . $options->get('zip.name'));
92+
93+
return $options;
94+
}
6595
}

0 commit comments

Comments
 (0)