mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-02-14 01:30:21 +00:00
Added patch chain to lock order of reverting - avoid demolishing own installation by accident.
Fix of some mistakes in Patch Chain.
This commit is contained in:
parent
13bc747b71
commit
1006702eb8
@ -82,6 +82,7 @@ abstract class Helper
|
||||
// Set name of the zip archive
|
||||
$options->set('zip.name', 'build.zip');
|
||||
$options->set('zip.log.name', 'deleted_files.log');
|
||||
$options->set('zip.chain.name', 'patch_chain.log');
|
||||
|
||||
// Set temp archive for extracting and downloading files
|
||||
$options->set('folder.temp', Factory::getConfig()->get('tmp_path'));
|
||||
|
@ -208,6 +208,7 @@ class PullModel extends AbstractModel
|
||||
$tempPath = $ciSettings->get('folder.temp') . "/$id";
|
||||
$backupsPath = $ciSettings->get('folder.backups') . "/$id";
|
||||
|
||||
$patchChainPath = $ciSettings->get('folder.backups') . '/' . $ciSettings->get('zip.chain.name');
|
||||
$delLogPath = $tempPath . '/' . $ciSettings->get('zip.log.name');
|
||||
$zipPath = $tempPath . '/' . $ciSettings->get('zip.name');
|
||||
|
||||
@ -317,6 +318,19 @@ class PullModel extends AbstractModel
|
||||
|
||||
$this->saveAppliedPatch($id, $files, $sha);
|
||||
|
||||
// Write or create patch chain for correct order of patching
|
||||
if (!file_exists($patchChainPath) || filesize($patchChainPath) === 0)
|
||||
{
|
||||
File::write($patchChainPath, $id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove any from php set EOL in log file, add id and rewrite file
|
||||
$patchChain = explode(PHP_EOL, file_get_contents($patchChainPath));
|
||||
$patchChain[] = $id;
|
||||
File::write($patchChainPath, implode(PHP_EOL, $patchChain));
|
||||
}
|
||||
|
||||
// Change the media version
|
||||
$version = new Version;
|
||||
$version->refreshMediaVersion();
|
||||
@ -608,6 +622,21 @@ class PullModel extends AbstractModel
|
||||
|
||||
$testRecord = $this->getTestRecord($id);
|
||||
|
||||
// Get PatchChain as array, remove any EOL set by php
|
||||
$patchChainPath = $ciSettings->get('folder.backups') . '/' . $ciSettings->get('zip.chain.name');
|
||||
$patchChain = array_reverse(explode(PHP_EOL, file_get_contents($patchChainPath)));
|
||||
|
||||
// Allow only reverts in order of the patch chain
|
||||
if ($patchChain[0] != $testRecord->pull_id)
|
||||
{
|
||||
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_NOT_IN_ORDER_OF_PATCHCHAIN', $patchChain[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
array_shift($patchChain);
|
||||
File::write($patchChainPath, implode(PHP_EOL, array_reverse($patchChain)));
|
||||
}
|
||||
|
||||
// We don't want to restore files from an older version
|
||||
if ($testRecord->applied_version != JVERSION)
|
||||
{
|
||||
|
@ -86,6 +86,7 @@ COM_PATCHTESTER_NO_CREDENTIALS = "In den Optionen wurden noch keine Benutzerdate
|
||||
COM_PATCHTESTER_NO_FILES_TO_PATCH = "Es sind keine Dateien aus diesem Pull Request zu patchen. Dies kann bedeuten, dass die Dateien des Pull Requests in Ihrer Installation nicht vorhanden sind."
|
||||
COM_PATCHTESTER_NO_ITEMS = "Es wurden noch keine Daten von Github abgerufen. Klicken Sie auf 'Daten abrufen' um die aktuellen Daten von Github zu holen."
|
||||
COM_PATCHTESTER_NOT_APPLIED = "Nicht angewendet"
|
||||
COM_PATCHTESTER_NOT_IN_ORDER_OF_PATCHCHAIN="Der Patch kann nicht zurückgesetzt werden, es muss zunächst erstmal der Patch mit der Pull ID %s zurückgesetzt werden."
|
||||
COM_PATCHTESTER_NOT_RTC = "Nicht RTC"
|
||||
COM_PATCHTESTER_READY_TO_COMMIT = "Ready to Commit"
|
||||
COM_PATCHTESTER_REPO_IS_GONE = "Der Patch konnte nicht angewendet werden, weil das Repository fehlt"
|
||||
|
@ -85,6 +85,7 @@ COM_PATCHTESTER_NO_CREDENTIALS="You have not entered your user credentials in th
|
||||
COM_PATCHTESTER_NO_FILES_TO_PATCH="There are no files to patch from this pull request. This may mean that the files in the pull request are not present in your installation."
|
||||
COM_PATCHTESTER_NO_ITEMS="No data has been retrieved from GitHub, please click the 'Fetch Data' button in the toolbar to retrieve the open pull requests."
|
||||
COM_PATCHTESTER_NOT_APPLIED="Not Applied"
|
||||
COM_PATCHTESTER_NOT_IN_ORDER_OF_PATCHCHAIN="You can't revert this patch, you need to revert the patch with the pull id %s first."
|
||||
COM_PATCHTESTER_NOT_RTC="Not RTC"
|
||||
COM_PATCHTESTER_PULL_ID="Pull ID"
|
||||
COM_PATCHTESTER_PULL_ID_ASC="Pull ID ascending"
|
||||
|
@ -86,6 +86,7 @@ COM_PATCHTESTER_NO_CREDENTIALS="You have not entered your user credentials in th
|
||||
COM_PATCHTESTER_NO_FILES_TO_PATCH="There are no files to patch from this pull request. This may mean that the files in the pull request are not present in your installation."
|
||||
COM_PATCHTESTER_NO_ITEMS="No data has been retrieved from GitHub, please click the 'Fetch Data' button in the toolbar to retrieve the open pull requests."
|
||||
COM_PATCHTESTER_NOT_APPLIED="Not Applied"
|
||||
COM_PATCHTESTER_NOT_IN_ORDER_OF_PATCHCHAIN="You can't revert this patch, you need to revert the patch with the pull id %s first."
|
||||
COM_PATCHTESTER_NOT_RTC="Not RTC"
|
||||
COM_PATCHTESTER_READY_TO_COMMIT="Ready to Commit"
|
||||
COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the repository is missing"
|
||||
|
@ -9,7 +9,8 @@
|
||||
"vendor-dir": "administrator/components/com_patchtester/vendor"
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3.10|^7.0"
|
||||
"php": "^7.0",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"php": "^5.6|^7.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user