33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-12-23 03:19:00 +00:00

Fix a couple of task references, URL encode patch URLs, cleanup PullModel (Fix #43)

This commit is contained in:
Michael Babker 2014-10-17 12:47:00 -04:00
parent 61f21236bc
commit d7b7915b22
4 changed files with 14 additions and 25 deletions

View File

@ -15,7 +15,7 @@ use PatchTester\Model\PullModel;
*
* @since 2.0
*/
class ApplyController extends \JControllerBase
class ApplyController extends DisplayController
{
/**
* Execute the controller.
@ -29,6 +29,10 @@ class ApplyController extends \JControllerBase
try
{
$model = new PullModel;
// Initialize the state for the model
$model->setState($this->initializeState($model));
$model->apply($this->getInput()->getUint('pull_id'));
$msg = \JText::_('COM_PATCHTESTER_APPLY_OK');

View File

@ -15,7 +15,7 @@ use PatchTester\Model\PullModel;
*
* @since 2.0
*/
class RevertController extends \JControllerBase
class RevertController extends DisplayController
{
/**
* Execute the controller.
@ -29,6 +29,10 @@ class RevertController extends \JControllerBase
try
{
$model = new PullModel;
// Initialize the state for the model
$model->setState($this->initializeState($model));
$model->revert($this->getInput()->getUint('pull_id'));
$msg = \JText::_('COM_PATCHTESTER_APPLY_OK');

View File

@ -27,25 +27,6 @@ class PullModel extends \JModelBase
*/
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
*
@ -149,7 +130,7 @@ class PullModel extends \JModelBase
// Only act if there are API hits remaining
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))
{
@ -203,7 +184,7 @@ class PullModel extends \JModelBase
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;
}

View File

@ -45,9 +45,9 @@ foreach ($this->items as $i => $item) :
</td>
<td class="center">
<?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 :
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; ?>
</td>
</tr>