mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-04-01 12:31:51 +00:00
Fix a couple of task references, URL encode patch URLs, cleanup PullModel (Fix #43)
This commit is contained in:
parent
61f21236bc
commit
d7b7915b22
@ -15,7 +15,7 @@ use PatchTester\Model\PullModel;
|
|||||||
*
|
*
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class ApplyController extends \JControllerBase
|
class ApplyController extends DisplayController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute the controller.
|
* Execute the controller.
|
||||||
@ -29,6 +29,10 @@ class ApplyController extends \JControllerBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$model = new PullModel;
|
$model = new PullModel;
|
||||||
|
|
||||||
|
// Initialize the state for the model
|
||||||
|
$model->setState($this->initializeState($model));
|
||||||
|
|
||||||
$model->apply($this->getInput()->getUint('pull_id'));
|
$model->apply($this->getInput()->getUint('pull_id'));
|
||||||
|
|
||||||
$msg = \JText::_('COM_PATCHTESTER_APPLY_OK');
|
$msg = \JText::_('COM_PATCHTESTER_APPLY_OK');
|
||||||
|
@ -15,7 +15,7 @@ use PatchTester\Model\PullModel;
|
|||||||
*
|
*
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class RevertController extends \JControllerBase
|
class RevertController extends DisplayController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute the controller.
|
* Execute the controller.
|
||||||
@ -29,6 +29,10 @@ class RevertController extends \JControllerBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$model = new PullModel;
|
$model = new PullModel;
|
||||||
|
|
||||||
|
// Initialize the state for the model
|
||||||
|
$model->setState($this->initializeState($model));
|
||||||
|
|
||||||
$model->revert($this->getInput()->getUint('pull_id'));
|
$model->revert($this->getInput()->getUint('pull_id'));
|
||||||
|
|
||||||
$msg = \JText::_('COM_PATCHTESTER_APPLY_OK');
|
$msg = \JText::_('COM_PATCHTESTER_APPLY_OK');
|
||||||
|
@ -27,25 +27,6 @@ class PullModel extends \JModelBase
|
|||||||
*/
|
*/
|
||||||
protected $nonProductionFolders = array('build', 'docs', 'installation', 'tests');
|
protected $nonProductionFolders = array('build', 'docs', 'installation', 'tests');
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to auto-populate the model state.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @note Calling getState() in this method will result in recursion.
|
|
||||||
* @since 2.0
|
|
||||||
*/
|
|
||||||
protected function populateState()
|
|
||||||
{
|
|
||||||
// Load the parameters.
|
|
||||||
$params = JComponentHelper::getParams('com_patchtester');
|
|
||||||
$this->setState('params', $params);
|
|
||||||
$this->setState('github_user', $params->get('org', 'joomla'));
|
|
||||||
$this->setState('github_repo', $params->get('repo', 'joomla-cms'));
|
|
||||||
|
|
||||||
parent::populateState();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to parse a patch and extract the affected files
|
* Method to parse a patch and extract the affected files
|
||||||
*
|
*
|
||||||
@ -149,7 +130,7 @@ class PullModel extends \JModelBase
|
|||||||
// Only act if there are API hits remaining
|
// Only act if there are API hits remaining
|
||||||
if ($github->authorization->getRateLimit()->rate->remaining > 0)
|
if ($github->authorization->getRateLimit()->rate->remaining > 0)
|
||||||
{
|
{
|
||||||
$pull = $github->pulls->get($this->getState('github_user'), $this->getState('github_repo'), $id);
|
$pull = $github->pulls->get($this->getState()->get('github_user'), $this->getState()->get('github_repo'), $id);
|
||||||
|
|
||||||
if (is_null($pull->head->repo))
|
if (is_null($pull->head->repo))
|
||||||
{
|
{
|
||||||
@ -203,7 +184,7 @@ class PullModel extends \JModelBase
|
|||||||
throw new \RuntimeException(sprintf(\JText::_('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S'), $file->old));
|
throw new \RuntimeException(sprintf(\JText::_('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S'), $file->old));
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' . $pull->head->ref . '/' . $file->new;
|
$url = 'https://raw.github.com/' . urlencode($pull->head->user->login) . '/' . urlencode($pull->head->repo->name) . '/' . urlencode($pull->head->ref) . '/' . $file->new;
|
||||||
|
|
||||||
$file->body = $transport->get($url)->body;
|
$file->body = $transport->get($url)->body;
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ foreach ($this->items as $i => $item) :
|
|||||||
</td>
|
</td>
|
||||||
<td class="center">
|
<td class="center">
|
||||||
<?php if ($item->applied) :
|
<?php if ($item->applied) :
|
||||||
echo '<a class="btn btn-small btn-success" href="javascript:submitpatch(\'pull.revert\', ' . (int) $item->applied . ');">' . \JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
|
echo '<a class="btn btn-small btn-success" href="javascript:submitpatch(\'revert\', ' . (int) $item->applied . ');">' . \JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
|
||||||
else :
|
else :
|
||||||
echo '<a class="btn btn-small btn-primary" href="javascript:submitpatch(\'pull.apply\', ' . (int) $item->pull_id . ');">' . \JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
|
echo '<a class="btn btn-small btn-primary" href="javascript:submitpatch(\'apply\', ' . (int) $item->pull_id . ');">' . \JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
|
||||||
endif; ?>
|
endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user