mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-12-22 02:49:01 +00:00
Formatting and fixes
This commit is contained in:
parent
d1a8e14e64
commit
edfce5445f
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<access component="com_patchtester">
|
||||
<section name="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
|
||||
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
|
||||
</section>
|
||||
<section name="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC"/>
|
||||
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC"/>
|
||||
</section>
|
||||
</access>
|
||||
|
@ -1,34 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<config>
|
||||
<fieldset name="component"
|
||||
label="COM_PATCHTESTER_COMPONENT_LABEL"
|
||||
description="COM_PATCHTESTER_COMPONENT_DESC"
|
||||
>
|
||||
<fieldset name="component"
|
||||
label="COM_PATCHTESTER_COMPONENT_LABEL"
|
||||
description="COM_PATCHTESTER_COMPONENT_DESC"
|
||||
>
|
||||
|
||||
<field name="org" type="text"
|
||||
default="joomla"
|
||||
description="COM_PATCHTESTER_FIELD_ORG_DESC"
|
||||
label="COM_PATCHTESTER_FIELD_ORG_LABEL"
|
||||
/>
|
||||
<field name="org" type="text"
|
||||
default="joomla"
|
||||
description="COM_PATCHTESTER_FIELD_ORG_DESC"
|
||||
label="COM_PATCHTESTER_FIELD_ORG_LABEL"
|
||||
/>
|
||||
|
||||
<field name="repo" type="text"
|
||||
default="joomla-cms"
|
||||
description="COM_PATCHTESTER_FIELD_REPO_DESC"
|
||||
label="COM_PATCHTESTER_FIELD_REPO_LABEL"
|
||||
/>
|
||||
<field name="repo" type="text"
|
||||
default="joomla-cms"
|
||||
description="COM_PATCHTESTER_FIELD_REPO_DESC"
|
||||
label="COM_PATCHTESTER_FIELD_REPO_LABEL"
|
||||
/>
|
||||
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="permissions"
|
||||
description="JCONFIG_PERMISSIONS_DESC"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
>
|
||||
<fieldset name="permissions"
|
||||
description="JCONFIG_PERMISSIONS_DESC"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
>
|
||||
|
||||
<field name="rules" type="rules"
|
||||
component="com_patchtester"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
section="component" />
|
||||
</fieldset>
|
||||
<field name="rules" type="rules"
|
||||
component="com_patchtester"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
section="component"/>
|
||||
</fieldset>
|
||||
</config>
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
@ -11,7 +11,7 @@ defined('_JEXEC') or die;
|
||||
/**
|
||||
* PatchTester Controller
|
||||
*
|
||||
* @package PatchTester
|
||||
* @package PatchTester
|
||||
*/
|
||||
class PatchTesterController extends JController
|
||||
{
|
||||
@ -20,11 +20,11 @@ class PatchTesterController extends JController
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
|
||||
*
|
||||
* @return JController This object to support chaining.
|
||||
* @since 1.5
|
||||
* @return JController This object to support chaining.
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = false)
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
@ -13,19 +13,22 @@ jimport('joomla.application.component.controllerform');
|
||||
/**
|
||||
* Pull controller class
|
||||
*
|
||||
* @package PatchTester
|
||||
* @package PatchTester
|
||||
*/
|
||||
class PatchtesterControllerPull extends JController
|
||||
{
|
||||
public function apply()
|
||||
{
|
||||
try {
|
||||
$model = $this->getModel('pull')
|
||||
->apply(JRequest::getVar('pull_id'));
|
||||
try
|
||||
{
|
||||
$this->getModel('pull')
|
||||
->apply(JRequest::getVar('pull_id'));
|
||||
|
||||
$msg = 'Patch successfully applied';
|
||||
$type = 'message';
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$msg = $e->getMessage();
|
||||
$type = 'error';
|
||||
}
|
||||
@ -35,14 +38,20 @@ class PatchtesterControllerPull extends JController
|
||||
|
||||
public function revert()
|
||||
{
|
||||
$model = $this->getModel('pull');
|
||||
if ($model->revert(JRequest::getVar('pull_id'))) {
|
||||
try
|
||||
{
|
||||
$this->getModel('pull')
|
||||
->revert(JRequest::getVar('pull_id'));
|
||||
|
||||
$msg = 'Patch successfully reverted';
|
||||
$type = 'message';
|
||||
} else {
|
||||
$msg = 'Patch did not revert';
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$msg = $e->getMessage() ?: 'Patch did not revert';
|
||||
$type = 'error';
|
||||
}
|
||||
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
@ -10,11 +10,10 @@ defined('_JEXEC') or die;
|
||||
/**
|
||||
* Methods supporting pull requests.
|
||||
*
|
||||
* @package PatchTester
|
||||
* @package PatchTester
|
||||
*/
|
||||
class PatchtesterModelPull extends JModel
|
||||
{
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
@ -40,11 +39,13 @@ class PatchtesterModelPull extends JModel
|
||||
|
||||
$lines = explode("\n", $patch);
|
||||
|
||||
foreach ($lines AS $line) {
|
||||
foreach ($lines AS $line)
|
||||
{
|
||||
switch ($state)
|
||||
{
|
||||
case 0:
|
||||
if (strpos($line, 'diff --git') === 0) {
|
||||
if (strpos($line, 'diff --git') === 0)
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
$file = new stdClass;
|
||||
@ -52,27 +53,33 @@ class PatchtesterModelPull extends JModel
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (strpos($line, 'index') === 0) {
|
||||
if (strpos($line, 'index') === 0)
|
||||
{
|
||||
$file->index = substr($line, 6);
|
||||
}
|
||||
|
||||
if (strpos($line, '---') === 0) {
|
||||
if (strpos($line, '---') === 0)
|
||||
{
|
||||
$file->old = substr($line, 6);
|
||||
}
|
||||
|
||||
if (strpos($line, '+++') === 0) {
|
||||
if (strpos($line, '+++') === 0)
|
||||
{
|
||||
$file->new = substr($line, 6);
|
||||
}
|
||||
|
||||
if (strpos($line, 'new file mode') === 0) {
|
||||
if (strpos($line, 'new file mode') === 0)
|
||||
{
|
||||
$file->action = 'added';
|
||||
}
|
||||
|
||||
if (strpos($line, 'deleted file mode') === 0) {
|
||||
if (strpos($line, 'deleted file mode') === 0)
|
||||
{
|
||||
$file->action = 'deleted';
|
||||
}
|
||||
|
||||
if (strpos($line, '@@') === 0) {
|
||||
if (strpos($line, '@@') === 0)
|
||||
{
|
||||
$state = 0;
|
||||
$files[] = $file;
|
||||
}
|
||||
@ -84,54 +91,62 @@ class PatchtesterModelPull extends JModel
|
||||
|
||||
public function apply($id)
|
||||
{
|
||||
jimport('joomla.client.github');
|
||||
jimport('joomla.client.curl');
|
||||
//@todo Use the JCurl class
|
||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/curl.php';
|
||||
|
||||
$table = JTable::getInstance('tests', 'PatchTesterTable');
|
||||
$github = new JGithub;
|
||||
$pull = $github->pulls->get($this->getState('github_user'), $this->getState('github_repo'), $id);
|
||||
|
||||
if (is_null($pull->head->repo)) {
|
||||
if (is_null($pull->head->repo))
|
||||
{
|
||||
throw new Exception(JText::_('COM_PATCHTESTER_REPO_IS_GONE'));
|
||||
}
|
||||
|
||||
$patch = JCurl::getAdapter($pull->diff_url)
|
||||
->fetch()->body;
|
||||
$patch = PTCurl::getAdapter($pull->diff_url)
|
||||
->fetch()->body;
|
||||
|
||||
$files = $this->parsePatch($patch);
|
||||
|
||||
foreach($files AS $file) {
|
||||
if ($file->action == 'deleted' && ! file_exists(JPATH_ROOT . '/' . $file->old)) {
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if ($file->action == 'deleted' && !file_exists(JPATH_ROOT . '/' . $file->old))
|
||||
{
|
||||
throw new Exception(sprintf(JText::_('COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S'), $file->old));
|
||||
}
|
||||
if ($file->action == 'added' || $file->action == 'modified') {
|
||||
if ($file->action == 'added' || $file->action == 'modified')
|
||||
{
|
||||
|
||||
// if the backup file already exists, we can't apply the patch
|
||||
if (file_exists(JPATH_COMPONENT . '/backups/' . md5($file->new) . '.txt')) {
|
||||
if (file_exists(JPATH_COMPONENT . '/backups/' . md5($file->new) . '.txt'))
|
||||
{
|
||||
throw new Exception(sprintf(JText::_('COM_PATCHTESTER_CONFLICT_S'), $file->new));
|
||||
}
|
||||
|
||||
if ($file->action == 'modified' && ! file_exists(JPATH_ROOT . '/' . $file->old)) {
|
||||
if ($file->action == 'modified' && !file_exists(JPATH_ROOT . '/' . $file->old))
|
||||
{
|
||||
throw new Exception(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;
|
||||
|
||||
$file->body = JCurl::getAdapter($url)
|
||||
->fetch()->body;
|
||||
$file->body = PTCurl::getAdapter($url)
|
||||
->fetch()->body;
|
||||
}
|
||||
}
|
||||
|
||||
// at this point, we have ensured that we have all the new files and there are no conflicts
|
||||
|
||||
foreach ($files AS $file)
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// we only create a backup if the file already exists
|
||||
if ($file->action == 'deleted' || (file_exists(JPATH_ROOT . '/' . $file->new) && $file->action == 'modified')) {
|
||||
if( ! JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file->old), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt')) {
|
||||
if ($file->action == 'deleted' || (file_exists(JPATH_ROOT . '/' . $file->new) && $file->action == 'modified'))
|
||||
{
|
||||
if (!JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file->old), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'))
|
||||
{
|
||||
throw new Exception(sprintf('Can not copy file %s to %s'
|
||||
, JPATH_ROOT . '/' . $file->old, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'));
|
||||
, JPATH_ROOT . '/' . $file->old, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,13 +154,15 @@ class PatchtesterModelPull extends JModel
|
||||
{
|
||||
case 'modified':
|
||||
case 'added':
|
||||
if( ! JFile::write(JPath::clean(JPATH_ROOT . '/' . $file->new), $file->body)) {
|
||||
if (!JFile::write(JPath::clean(JPATH_ROOT . '/' . $file->new), $file->body))
|
||||
{
|
||||
throw new Exception(sprintf('Can not write the file: %s', JPATH_ROOT . '/' . $file->new));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'deleted':
|
||||
if( ! JFile::delete(JPATH::clean(JPATH_ROOT . '/' . $file->old))) {
|
||||
if (!JFile::delete(JPATH::clean(JPATH_ROOT . '/' . $file->old)))
|
||||
{
|
||||
throw new Exception(sprintf('Can not delete the file: %s', JPATH_ROOT . '/' . $file->old));
|
||||
}
|
||||
break;
|
||||
@ -159,7 +176,8 @@ class PatchtesterModelPull extends JModel
|
||||
$version = new JVersion;
|
||||
$table->applied_version = $version->getShortVersion();
|
||||
|
||||
if ( ! $table->store()) {
|
||||
if (!$table->store())
|
||||
{
|
||||
throw new Exception($table->getError());
|
||||
}
|
||||
|
||||
@ -174,41 +192,64 @@ class PatchtesterModelPull extends JModel
|
||||
|
||||
// we don't want to restore files from an older version
|
||||
$version = new JVersion;
|
||||
if ($table->applied_version != $version->getShortVersion()) {
|
||||
|
||||
if ($table->applied_version != $version->getShortVersion())
|
||||
{
|
||||
/*
|
||||
$table->applied = 0;
|
||||
$table->applied_version = '';
|
||||
$table->store();
|
||||
*/
|
||||
$table->delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
$files = json_decode($table->data);
|
||||
|
||||
foreach ($files AS $file) {
|
||||
switch ($file->action) {
|
||||
if (!$files)
|
||||
{
|
||||
throw new Exception(sprintf('%s - Error retrieving table data (%s)'
|
||||
, __METHOD__, htmlentities($table->data)));
|
||||
}
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
switch ($file->action)
|
||||
{
|
||||
case 'deleted':
|
||||
case 'modified':
|
||||
if ( ! JFile::copy(JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt', JPATH_ROOT . '/' . $file->old)) {
|
||||
if (!JFile::copy(
|
||||
JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'
|
||||
, JPATH_ROOT . '/' . $file->old)
|
||||
)
|
||||
{
|
||||
throw new Exception(sprintf('Can not copy file %s to %s'
|
||||
, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'
|
||||
, JPATH_ROOT . '/' . $file->old));
|
||||
, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'
|
||||
, JPATH_ROOT . '/' . $file->old));
|
||||
}
|
||||
if ( ! JFile::delete(JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt')) {
|
||||
|
||||
if (!JFile::delete(JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'))
|
||||
{
|
||||
throw new Exception(sprintf('Can not delete the file: %s'
|
||||
, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'));
|
||||
, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'added':
|
||||
if ( ! JFile::delete(JPath::clean(JPATH_ROOT . '/' . $file->new))) {
|
||||
if (!JFile::delete(JPath::clean(JPATH_ROOT . '/' . $file->new)))
|
||||
{
|
||||
throw new Exception(sprintf('Can not delete the file: %s', JPATH_ROOT . '/' . $file->new));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$table->applied_version = '';
|
||||
$table->applied = 0;
|
||||
$table->store();
|
||||
*/
|
||||
$table->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
@ -12,7 +12,7 @@ jimport('joomla.application.component.modellist');
|
||||
/**
|
||||
* Methods supporting a list of pull request.
|
||||
*
|
||||
* @package PatchTester
|
||||
* @package PatchTester
|
||||
*/
|
||||
class PatchtesterModelPulls extends JModelList
|
||||
{
|
||||
@ -20,13 +20,15 @@ class PatchtesterModelPulls extends JModelList
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array An optional associative array of configuration settings.
|
||||
* @see JController
|
||||
* @since 1.6
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @see JController
|
||||
* @since 11.1
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'id', 'id',
|
||||
'title', 'title',
|
||||
@ -44,15 +46,15 @@ class PatchtesterModelPulls extends JModelList
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
// Load the filter state.
|
||||
$search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
|
||||
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
$searchId = $this->getUserStateFromRequest($this->context.'.filter.searchid', 'filter_searchid');
|
||||
$searchId = $this->getUserStateFromRequest($this->context . '.filter.searchid', 'filter_searchid');
|
||||
$this->setState('filter.searchid', $searchId);
|
||||
|
||||
// Load the parameters.
|
||||
@ -73,9 +75,10 @@ class PatchtesterModelPulls extends JModelList
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
* @return string A store id.
|
||||
* @since 1.6
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
@ -86,7 +89,7 @@ class PatchtesterModelPulls extends JModelList
|
||||
{
|
||||
$query = $this->_db->getQuery(true);
|
||||
$query->select('*');
|
||||
$query->from('#__tests');
|
||||
$query->from('#__patchtester_tests');
|
||||
$query->where('applied = 1');
|
||||
|
||||
$this->_db->setQuery($query);
|
||||
@ -98,7 +101,8 @@ class PatchtesterModelPulls extends JModelList
|
||||
{
|
||||
jimport('joomla.client.github');
|
||||
|
||||
if ($this->getState('github_user') == '' || $this->getState('github_repo') == '') {
|
||||
if ($this->getState('github_user') == '' || $this->getState('github_repo') == '')
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
@ -107,28 +111,57 @@ class PatchtesterModelPulls extends JModelList
|
||||
$search = $this->getState('filter.search');
|
||||
$searchId = $this->getState('filter.searchid');
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
$github = new JGithub();
|
||||
$pulls = $github->pulls->getAll($this->getState('github_user'), $this->getState('github_repo'));
|
||||
$pulls = $github->pulls->getList($this->getState('github_user'), $this->getState('github_repo'));
|
||||
usort($pulls, array($this, 'sortItems'));
|
||||
|
||||
foreach ($pulls AS $i => &$pull)
|
||||
foreach ($pulls as $i => &$pull)
|
||||
{
|
||||
if($search && false === strpos($pull->title, $search)) {
|
||||
if ($search && false === strpos($pull->title, $search))
|
||||
{
|
||||
unset($pulls[$i]);
|
||||
continue;
|
||||
}
|
||||
if($searchId && $pull->number != $searchId) {
|
||||
|
||||
if ($searchId && $pull->number != $searchId)
|
||||
{
|
||||
unset($pulls[$i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try to find a joomlacode issue number
|
||||
$pulls[$i]->joomlacode_issue = 0;
|
||||
|
||||
$matches = array();
|
||||
|
||||
preg_match('#\[\#([0-9]+)\]#', $pull->title, $matches);
|
||||
$pull->joomlacode_issue = isset($matches[1]) ? $matches[1] : 0;
|
||||
|
||||
if (isset($matches[1]))
|
||||
{
|
||||
$pulls[$i]->joomlacode_issue = (int) $matches[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
preg_match('#(http://joomlacode[-\w\./\?\S]+)#', $pull->body, $matches);
|
||||
|
||||
if (isset($matches[1]))
|
||||
{
|
||||
preg_match('#tracker_item_id=([0-9]+)#', $matches[1], $matches);
|
||||
|
||||
if (isset($matches[1]))
|
||||
{
|
||||
$pulls[$i]->joomlacode_issue = (int) $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $pulls;
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return array();
|
||||
@ -144,7 +177,7 @@ class PatchtesterModelPulls extends JModelList
|
||||
|
||||
case 'number' :
|
||||
default :
|
||||
return ($this->orderDir == 'asc') ? $b->number < $a->number : $b->number > $a->number;
|
||||
return ($this->orderDir == 'asc') ? $b->number < $a->number : $b->number > $a->number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
|
||||
@ -10,13 +10,14 @@
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Access check.
|
||||
if (!JFactory::getUser()->authorise('core.manage', 'com_patchtester')) {
|
||||
if (!JFactory::getUser()->authorise('core.manage', 'com_patchtester'))
|
||||
{
|
||||
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
|
||||
}
|
||||
|
||||
// Include dependencies
|
||||
jimport('joomla.application.component.controller');
|
||||
|
||||
$controller = JController::getInstance('PatchTester');
|
||||
$controller = JController::getInstance('PatchTester');
|
||||
$controller->execute(JRequest::getCmd('task'));
|
||||
$controller->redirect();
|
||||
|
@ -1,51 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="1.7" method="upgrade">
|
||||
<name>com_patchtester</name>
|
||||
<author>Ian MacLennan</author>
|
||||
<creationDate>October 2011</creationDate>
|
||||
<copyright>(C) 2011 Ian MacLennan. All rights reserved.
|
||||
</copyright>
|
||||
<license>GNU General Public License version 2 or later; see
|
||||
LICENSE.txt</license>
|
||||
<authorEmail>ianlenmac@gmail.com</authorEmail>
|
||||
<authorUrl>http://github.com/ianmacl</authorUrl>
|
||||
<version>1.0alpha</version>
|
||||
<description>COM_PATCHTESTER_XML_DESCRIPTION</description>
|
||||
<name>com_patchtester</name>
|
||||
<author>Ian MacLennan</author>
|
||||
<creationDate>October 2011</creationDate>
|
||||
<copyright>(C) 2011 Ian MacLennan. All rights reserved.
|
||||
</copyright>
|
||||
<license>GNU General Public License version 2 or later; see
|
||||
LICENSE.txt
|
||||
</license>
|
||||
<authorEmail>ianlenmac@gmail.com</authorEmail>
|
||||
<authorUrl>http://github.com/ianmacl</authorUrl>
|
||||
<version>1.0alpha</version>
|
||||
<description>COM_PATCHTESTER_XML_DESCRIPTION</description>
|
||||
|
||||
<install> <!-- Runs on install -->
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
<install> <!-- Runs on install -->
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</install>
|
||||
<uninstall> <!-- Runs on uninstall -->
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</uninstall>
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</uninstall>
|
||||
|
||||
<files folder="site">
|
||||
<filename>patchtester.php</filename>
|
||||
</files>
|
||||
<administration>
|
||||
<menu img="components/com_patchtester/assets/images/icon-16-patchtester.png">com_patchtester</menu>
|
||||
<files folder="admin">
|
||||
<filename>access.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
<filename>controller.php</filename>
|
||||
<filename>patchtester.php</filename>
|
||||
<folder>assets</folder>
|
||||
<folder>controllers</folder>
|
||||
<folder>models</folder>
|
||||
<folder>sql</folder>
|
||||
<folder>tables</folder>
|
||||
<folder>views</folder>
|
||||
<folder>language</folder>
|
||||
</files>
|
||||
</administration>
|
||||
<files folder="site">
|
||||
<filename>patchtester.php</filename>
|
||||
</files>
|
||||
<administration>
|
||||
<menu img="components/com_patchtester/assets/images/icon-16-patchtester.png">com_patchtester</menu>
|
||||
<files folder="admin">
|
||||
<filename>access.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
<filename>controller.php</filename>
|
||||
<filename>patchtester.php</filename>
|
||||
<folder>assets</folder>
|
||||
<folder>controllers</folder>
|
||||
<folder>models</folder>
|
||||
<folder>sql</folder>
|
||||
<folder>tables</folder>
|
||||
<folder>views</folder>
|
||||
<folder>language</folder>
|
||||
</files>
|
||||
</administration>
|
||||
|
||||
<!-- Extension Update Specification -->
|
||||
<updateservers>
|
||||
<server type="extension">https://raw.github.com/ianmacl/patchtester/master/updates/patchtester.xml</server>
|
||||
</updateservers>
|
||||
<!-- Extension Update Specification -->
|
||||
<updateservers>
|
||||
<server type="extension">https://raw.github.com/ianmacl/patchtester/master/updates/patchtester.xml</server>
|
||||
</updateservers>
|
||||
|
||||
</extension>
|
||||
|
@ -1,7 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS `#__tests` (
|
||||
CREATE TABLE IF NOT EXISTS `#__patchtester_tests` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`pull_id` int(11) NOT NULL,
|
||||
`data` text NOT NULL,
|
||||
`data` longtext NOT NULL,
|
||||
`patched_by` int(11) NOT NULL,
|
||||
`applied` int(11) NOT NULL,
|
||||
`applied_version` varchar(25) NOT NULL,
|
||||
|
@ -1 +1 @@
|
||||
DROP TABLE IF EXISTS `#__tests`
|
||||
DROP TABLE IF EXISTS `#__patchtester_tests`
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
@ -11,17 +11,17 @@ defined('_JEXEC') or die;
|
||||
/**
|
||||
* Tests Table class
|
||||
*
|
||||
* @package PatchTester
|
||||
* @package PatchTester
|
||||
*/
|
||||
class PatchtesterTableTests extends JTable
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param JDatabase A database connector object
|
||||
* @param JDatabase $db A database connector object
|
||||
*/
|
||||
public function __construct(&$db)
|
||||
{
|
||||
parent::__construct('#__tests', 'id', $db);
|
||||
parent::__construct('#__patchtester_tests', 'id', $db);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
@ -13,7 +13,7 @@ jimport('joomla.application.component.view');
|
||||
/**
|
||||
* View class for a list of pull requests.
|
||||
*
|
||||
* @package PatchTester
|
||||
* @package PatchTester
|
||||
*/
|
||||
class PatchtesterViewPulls extends JView
|
||||
{
|
||||
@ -25,12 +25,13 @@ class PatchtesterViewPulls extends JView
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->state = $this->get('State');
|
||||
$this->items = $this->get('Items');
|
||||
$this->patches = $this->get('AppliedPatches');
|
||||
$this->state = $this->get('State');
|
||||
$this->items = $this->get('Items');
|
||||
$this->patches = $this->get('AppliedPatches');
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors'))) {
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
JError::raiseError(500, implode("\n", $errors));
|
||||
return false;
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/bin/sh
|
||||
rm -rf site
|
||||
rm -rf admin
|
||||
rm -rf ../patchtester.tar.bz2
|
||||
@ -6,6 +7,7 @@ cp -r ../components/com_patchtester site
|
||||
rm -rf admin/backups/*.txt
|
||||
mv admin/patchtester.xml patchtester.xml
|
||||
tar jcf ../com_patchtester.tar.bz2 site admin patchtester.xml
|
||||
tar zcf ../com_patchtester.tar.gz site admin patchtester.xml
|
||||
|
||||
rm -rf github
|
||||
mkdir github
|
||||
@ -15,5 +17,7 @@ cp ../libraries/joomla/client/curl.php github
|
||||
cp -r ../libraries/joomla/client/github github
|
||||
cp github.xml github
|
||||
tar jcf ../file_github.tar.bz2 github/*
|
||||
tar zcf ../file_github.tar.gz github/*
|
||||
|
||||
tar jcf ../pkg_patchtester.tar.bz2 pkg_patchtester.xml ../com_patchtester.tar.bz2 ../file_github.tar.bz2
|
||||
tar zcf ../pkg_patchtester.tar.gz pkg_patchtester_gz.xml ../com_patchtester.tar.gz ../file_github.tar.gz
|
||||
|
Loading…
Reference in New Issue
Block a user