Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions administrator/components/com_patchtester/controllers/pull.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@ public function apply()
$model = $this->getModel('pull');
if ($model->apply(JRequest::getVar('pull_id'))) {
$msg = 'Patch successfully applied';
$type = 'message';
} else {
$msg = $model->getError();
$type = 'error';
}
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg);
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type);
}

public function revert()
{
$model = $this->getModel('pull');
if ($model->revert(JRequest::getVar('pull_id'))) {
$msg = 'Patch successfully reverted';
$type = 'message';
} else {
$msg = 'Patch did not revert';
$type = 'error';
}
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg);
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the reposit
COM_PATCHTESTER_CONFLICT="The patch could not be applied because it conflicts with a previously applied patch"
COM_PATCHTESTER_COMPONENT_LABEL="Patch Tester"
COM_PATCHTESTER_COMPONENT_DESC="Patch Tester Configuration Values"
COM_PATCHTESTER_FIELD_ORG_DESC="Github Username"
COM_PATCHTESTER_FIELD_ORG_LABEL="Name of account on Github of which to monitor pull requests"
COM_PATCHTESTER_FIELD_REPO_DESC="Github Repository"
COM_PATCHTESTER_FIELD_REPO_LABEL="Name of repository on Github of which to monitor pull requests"
COM_PATCHTESTER_FIELD_ORG_LABEL="Github Username"
COM_PATCHTESTER_FIELD_ORG_DESC="Name of account on Github of which to monitor pull requests"
COM_PATCHTESTER_FIELD_REPO_LABEL="Github Repository"
COM_PATCHTESTER_FIELD_REPO_DESC="Name of repository on Github of which to monitor pull requests"
COM_PATCHTESTER_JOOMLACODE_ISSUE="Joomlacode Issue"
40 changes: 18 additions & 22 deletions administrator/components/com_patchtester/models/pull.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,23 @@
class PatchtesterModelPull extends JModel
{

/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
// Initialise variables.
$app = JFactory::getApplication('administrator');

// Load the parameters.
$params = JComponentHelper::getParams('com_patchtester');
$this->setState('params', $params);
$this->setState('github_user', $params->get('org'));
$this->setState('github_repo', $params->get('repo'));

parent::populateState();
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
// Load the parameters.
$params = JComponentHelper::getParams('com_patchtester');
$this->setState('params', $params);
$this->setState('github_user', $params->get('org'));
$this->setState('github_repo', $params->get('repo'));

parent::populateState();
}

protected function parsePatch($patch)
{
Expand Down Expand Up @@ -112,7 +108,7 @@ public function apply($id)
$http = new JHttp;

$url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' .
$pull->head->ref . '/' . $file->new;
$pull->head->ref . '/' . $file->new;


// if the backup file already exists, we can't apply the patch
Expand Down Expand Up @@ -140,7 +136,7 @@ public function apply($id)
foreach ($files AS $file)
{
// we only create a backup if the file already exists
if (file_exists(JPATH_ROOT . '/' . $file->new) && ($file->action == 'modified' || $file->action == 'deleted')) {
if ($file->action == 'deleted' || (file_exists(JPATH_ROOT . '/' . $file->new) && $file->action == 'modified')) {
JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file->old), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt');
}

Expand Down