33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2025-01-23 23:28:24 +00:00

Fixes to previous commit.

This commit is contained in:
datsepp 2019-09-12 12:58:17 +02:00
parent 26b5399df6
commit 4ffb145b61
9 changed files with 25 additions and 24 deletions

View File

@ -44,12 +44,12 @@ class ResetController extends AbstractController
// Check the applied patches in the database first // Check the applied patches in the database first
$appliedPatches = $pullModel->getPatchesDividedInProcs(); $appliedPatches = $pullModel->getPatchesDividedInProcs();
if (count($appliedPatches[0])) if (count($appliedPatches["git"]))
{ {
$revertErrored = false; $revertErrored = false;
// Let's try to cleanly revert all applied patches // Let's try to cleanly revert all applied patches
foreach ($appliedPatches as $patch) foreach ($appliedPatches["git"] as $patch)
{ {
try try
{ {
@ -62,16 +62,17 @@ class ResetController extends AbstractController
} }
} }
if (count($appliedPatches[1])) if (count($appliedPatches["ci"]))
{ {
$revertErrored = false; $revertErrored = false;
// Let's try to cleanly revert all applied patches with ci // Let's try to cleanly revert all applied patches with ci
foreach ($appliedPatches as $patch) foreach ($appliedPatches["ci"] as $patch)
{ {
try try
{ {
$pullModel->revertWithCIServer($patch->id); $pullModel->revertWithCIServer($patch->insert_id);
} }
catch (\RuntimeException $e) catch (\RuntimeException $e)
{ {

View File

@ -82,7 +82,6 @@ abstract class Helper
// Set name of the zip archive // Set name of the zip archive
$options->set('zip.name', 'build.zip'); $options->set('zip.name', 'build.zip');
$options->set('zip.log.name', 'deleted_files.log'); $options->set('zip.log.name', 'deleted_files.log');
$options->set('zip.chain.name', 'patch_chain.json');
// Set temp archive for extracting and downloading files // Set temp archive for extracting and downloading files
$options->set('folder.temp', Factory::getConfig()->get('tmp_path')); $options->set('folder.temp', Factory::getConfig()->get('tmp_path'));

View File

@ -618,13 +618,13 @@ class PullModel extends AbstractModel
$patchChain = $this->getLastChain(); $patchChain = $this->getLastChain();
// Allow only reverts in order of the patch chain // Allow only reverts in order of the patch chain
if ($patchChain[0]->insert_id != $id) if ($patchChain->insert_id != $id)
{ {
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_NOT_IN_ORDER_OF_PATCHCHAIN', $patchChain[0]->pull_id)); throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_NOT_IN_ORDER_OF_PATCHCHAIN', $patchChain->pull_id));
} }
else else
{ {
$this->removeLastChain($patchChain[0]->insert_id); $this->removeLastChain($patchChain->insert_id);
} }
// We don't want to restore files from an older version // We don't want to restore files from an older version
@ -910,14 +910,15 @@ class PullModel extends AbstractModel
$appliedByGit = $db->setQuery( $appliedByGit = $db->setQuery(
$db->getQuery(true) $db->getQuery(true)
->select('pulls.id, pulls.pull_id') ->select('tests.id, tests.pull_id')
->from('#__patchtester_chain chain') ->from('#__patchtester_tests tests')
->leftJoin('#__patchtester_pulls pulls', 'chain.id != pulls.id') ->leftJoin('#__patchtester_chain chain', 'tests.id = chain.insert_id')
)->loadObject(); ->where('chain.insert_id IS NULL')
)->loadObjectList('pull_id');
$appliedByCI = $this->getPatchChain(); $appliedByCI = $this->getPatchChain();
return [$appliedByGit, $appliedByCI]; return ["git" => $appliedByGit, "ci" => $appliedByCI];
} }
/** /**

View File

@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS `#__patchtester_tests` (
CREATE TABLE IF NOT EXISTS `#__patchtester_chain` ( CREATE TABLE IF NOT EXISTS `#__patchtester_chain` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`insert_id` int(11) NOT NULL `insert_id` int(11) NOT NULL,
`pull_id` int(11) NOT NULL `pull_id` int(11) NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

View File

@ -23,6 +23,6 @@ CREATE TABLE IF NOT EXISTS "#__patchtester_tests" (
CREATE TABLE IF NOT EXISTS "#__patchtester_chain" ( CREATE TABLE IF NOT EXISTS "#__patchtester_chain" (
"id" serial NOT NULL, "id" serial NOT NULL,
"insert_id" bigint NOT NULL, "insert_id" bigint NOT NULL,
"pull_id" bigint NOT NULL "pull_id" bigint NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
); );

View File

@ -28,8 +28,8 @@ CREATE TABLE [#__patchtester_tests](
CREATE TABLE [#__patchtester_chain] ( CREATE TABLE [#__patchtester_chain] (
[id] [bigint] IDENTITY(1,1) NOT NULL, [id] [bigint] IDENTITY(1,1) NOT NULL,
[insert_id] [bigint] NOT NULL [insert_id] [bigint] NOT NULL,
[pull_id] [bigint] NOT NULL [pull_id] [bigint] NOT NULL,
CONSTRAINT [PK_#__patchtester_chain] PRIMARY KEY CLUSTERED CONSTRAINT [PK_#__patchtester_chain] PRIMARY KEY CLUSTERED
( (
[id] ASC [id] ASC

View File

@ -1,6 +1,6 @@
CREATE TABLE IF NOT EXISTS `#__patchtester_chain` ( CREATE TABLE IF NOT EXISTS `#__patchtester_chain` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`insert_id` int(11) NOT NULL `insert_id` int(11) NOT NULL,
`pull_id` int(11) NOT NULL `pull_id` int(11) NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

View File

@ -1,6 +1,6 @@
CREATE TABLE IF NOT EXISTS "#__patchtester_chain" ( CREATE TABLE IF NOT EXISTS "#__patchtester_chain" (
"id" serial NOT NULL, "id" serial NOT NULL,
"insert_id" bigint NOT NULL, "insert_id" bigint NOT NULL,
"pull_id" bigint NOT NULL "pull_id" bigint NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
); );

View File

@ -1,7 +1,7 @@
CREATE TABLE [#__patchtester_chain] ( CREATE TABLE [#__patchtester_chain] (
[id] [bigint] IDENTITY(1,1) NOT NULL, [id] [bigint] IDENTITY(1,1) NOT NULL,
[insert_id] [bigint] NOT NULL [insert_id] [bigint] NOT NULL,
[pull_id] [bigint] NOT NULL [pull_id] [bigint] NOT NULL,
CONSTRAINT [PK_#__patchtester_chain] PRIMARY KEY CLUSTERED CONSTRAINT [PK_#__patchtester_chain] PRIMARY KEY CLUSTERED
( (
[id] ASC [id] ASC