mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-01-23 07:08:33 +00:00
Only store/display commit SHA for applied patches
This commit is contained in:
parent
d7057adff6
commit
0f47672813
@ -179,30 +179,6 @@ class PullModel extends \JModelDatabase
|
||||
throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage()), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
// Compare the pull's HEAD SHA to what patch tester has pulled; if it's newer set a flag
|
||||
try
|
||||
{
|
||||
$db = $this->getDb();
|
||||
$stateSha = $db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->select('sha')
|
||||
->from($db->quoteName('#__patchtester_pulls'))
|
||||
->where($db->quoteName('pull_id') . ' = ' . (int) $id)
|
||||
)->loadResult();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
// Not a fatal error, keep on truckin'
|
||||
$stateSha = false;
|
||||
}
|
||||
|
||||
if ($stateSha && $stateSha !== $pull->head->sha)
|
||||
{
|
||||
$this->getState()->set('pull.sha_different', true);
|
||||
$this->getState()->set('pull.applied_sha', $pull->head->sha);
|
||||
$this->getState()->set('pull.state_sha', $stateSha);
|
||||
}
|
||||
|
||||
$files = $this->parsePatch($patch);
|
||||
|
||||
if (!$files)
|
||||
@ -298,6 +274,15 @@ class PullModel extends \JModelDatabase
|
||||
throw new \RuntimeException($table->getError());
|
||||
}
|
||||
|
||||
// Insert the retrieved commit SHA into the pulls table for this item
|
||||
$db = $this->getDb();
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update('#__patchtester_pulls')
|
||||
->set('sha = ' . $db->quote($pull->head->sha))
|
||||
->where($db->quoteName('pull_id') . ' = ' . (int) $id)
|
||||
)->execute();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -320,9 +305,19 @@ class PullModel extends \JModelDatabase
|
||||
// We don't want to restore files from an older version
|
||||
if ($table->applied_version != JVERSION)
|
||||
{
|
||||
// Remove the retrieved commit SHA from the pulls table for this item
|
||||
$db = $this->getDb();
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update('#__patchtester_pulls')
|
||||
->set('sha = ' . $db->quote(''))
|
||||
->where($db->quoteName('pull_id') . ' = ' . (int) $table->pull_id)
|
||||
)->execute();
|
||||
|
||||
// And delete the record from the tests table
|
||||
$table->delete();
|
||||
|
||||
return $this;
|
||||
return true;
|
||||
}
|
||||
|
||||
$files = json_decode($table->data);
|
||||
@ -378,6 +373,16 @@ class PullModel extends \JModelDatabase
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the retrieved commit SHA from the pulls table for this item
|
||||
$db = $this->getDb();
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update('#__patchtester_pulls')
|
||||
->set('sha = ' . $db->quote(''))
|
||||
->where($db->quoteName('pull_id') . ' = ' . (int) $table->pull_id)
|
||||
)->execute();
|
||||
|
||||
// And delete the record from the tests table
|
||||
$table->delete();
|
||||
|
||||
return true;
|
||||
|
@ -75,9 +75,6 @@ $filterApplied = $this->escape($this->state->get('filter.applied'));
|
||||
<th class="nowrap">
|
||||
<?php echo \JText::_('JGLOBAL_TITLE'); ?>
|
||||
</th>
|
||||
<th class="nowrap">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_SHA'); ?>
|
||||
</th>
|
||||
<th width="8%" class="nowrap center">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>
|
||||
</th>
|
||||
|
@ -21,9 +21,11 @@ foreach ($this->items as $i => $item) :
|
||||
</td>
|
||||
<td>
|
||||
<span class="hasTooltip" title="<strong>Info</strong><br/><?php echo $this->escape($item->description); ?>"><?php echo $this->escape($item->title); ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo substr($item->sha, 0, 10); ?>
|
||||
<?php if ($item->applied) : ?>
|
||||
<div class="small">
|
||||
<span class="label label-info"><?php echo \JText::sprintf('COM_PATCHTESTER_APPLIED_COMMIT_SHA', substr($item->sha, 0, 10)); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<a class="btn btn-small btn-info" href="<?php echo $item->pull_url; ?>" target="_blank">
|
||||
@ -39,9 +41,9 @@ foreach ($this->items as $i => $item) :
|
||||
<?php endif; ?>
|
||||
<td class="center">
|
||||
<?php if ($item->applied) : ?>
|
||||
<span class="label label-success">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_APPLIED'); ?>
|
||||
</span>
|
||||
<div>
|
||||
<span class="label label-success"><?php echo \JText::_('COM_PATCHTESTER_APPLIED'); ?></span>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<span class="label">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_NOT_APPLIED'); ?>
|
||||
@ -49,11 +51,11 @@ foreach ($this->items as $i => $item) :
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($item->applied) :
|
||||
echo '<a class="btn btn-small btn-success" href="javascript:PatchTester.submitpatch(\'revert\', ' . (int) $item->applied . ');">' . \JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
|
||||
else :
|
||||
echo '<a class="btn btn-small btn-primary" href="javascript:PatchTester.submitpatch(\'apply\', ' . (int) $item->pull_id . ');">' . \JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
|
||||
endif; ?>
|
||||
<?php if ($item->applied) : ?>
|
||||
<a class="btn btn-small btn-success" href="javascript:PatchTester.submitpatch('revert', '<?php echo (int) $item->applied; ?>');"><?php echo \JText::_('COM_PATCHTESTER_REVERT_PATCH'); ?></a><br />
|
||||
<?php else : ?>
|
||||
<a class="btn btn-small btn-primary" href="javascript:PatchTester.submitpatch('apply', '<?php echo (int) $item->pull_id; ?>');"><?php echo \JText::_('COM_PATCHTESTER_APPLY_PATCH'); ?></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;
|
||||
|
@ -7,6 +7,7 @@ COM_PATCHTESTER="Joomla! Patch Tester"
|
||||
COM_PATCHTESTER_API_LIMIT_ACTION="The GitHub API rate limit has been reached for this resource, could not connect to GitHub to perform the requested action. The rate limit will reset at %s"
|
||||
COM_PATCHTESTER_API_LIMIT_LIST="The GitHub API rate limit has been reached for this resource, could not connect to GitHub for updated data. The rate limit will reset at %s"
|
||||
COM_PATCHTESTER_APPLIED="Applied"
|
||||
COM_PATCHTESTER_APPLIED_COMMIT_SHA="Applied Commit SHA: %s"
|
||||
COM_PATCHTESTER_APPLY_OK="Patch successfully applied"
|
||||
COM_PATCHTESTER_APPLY_PATCH="Apply Patch"
|
||||
COM_PATCHTESTER_COMPONENT_DESC="Joomla! Patch Tester Configuration Values"
|
||||
@ -67,4 +68,3 @@ COM_PATCHTESTER_REVERT_PATCH="Revert Patch"
|
||||
COM_PATCHTESTER_TEST_THIS_PATCH="Test This Patch"
|
||||
COM_PATCHTESTER_TOOLBAR_FETCH_DATA="Fetch Data"
|
||||
COM_PATCHTESTER_TOOLBAR_RESET="Reset"
|
||||
COM_PATCHTESTER_SHA="SHA"
|
||||
|
@ -23,6 +23,11 @@ foreach ($this->items as $i => $item) :
|
||||
<p class="hasTooltip" title="<?php echo $this->escape($item->description); ?>">
|
||||
<?php echo $this->escape($item->title); ?>
|
||||
</p>
|
||||
<?php if ($item->applied) : ?>
|
||||
<p class="smallsub">
|
||||
<span class="label label-info"><?php echo \JText::sprintf('COM_PATCHTESTER_APPLIED_COMMIT_SHA', substr($item->sha, 0, 10)); ?></span>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-small btn-info" href="<?php echo $item->pull_url; ?>" target="_blank">
|
||||
@ -38,21 +43,17 @@ foreach ($this->items as $i => $item) :
|
||||
<?php endif; ?>
|
||||
<td class="center">
|
||||
<?php if ($item->applied) : ?>
|
||||
<span class="label label-success">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_APPLIED'); ?>
|
||||
</span>
|
||||
<span class="label label-success"><?php echo \JText::_('COM_PATCHTESTER_APPLIED'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="label">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_NOT_APPLIED'); ?>
|
||||
</span>
|
||||
<span class="label"><?php echo \JText::_('COM_PATCHTESTER_NOT_APPLIED'); ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($item->applied) :
|
||||
echo '<a class="btn btn-small btn-success" href="javascript:PatchTester.submitpatch(\'revert\', ' . (int) $item->applied . ');">' . \JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
|
||||
else :
|
||||
echo '<a class="btn btn-small btn-primary" href="javascript:PatchTester.submitpatch(\'apply\', ' . (int) $item->pull_id . ');">' . \JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
|
||||
endif; ?>
|
||||
<?php if ($item->applied) : ?>
|
||||
<a class="btn btn-small btn-success" href="javascript:PatchTester.submitpatch('revert', '<?php echo (int) $item->applied; ?>');"><?php echo \JText::_('COM_PATCHTESTER_REVERT_PATCH'); ?></a><br />
|
||||
<?php else : ?>
|
||||
<a class="btn btn-small btn-primary" href="javascript:PatchTester.submitpatch('apply', '<?php echo (int) $item->pull_id; ?>');"><?php echo \JText::_('COM_PATCHTESTER_APPLY_PATCH'); ?></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;
|
||||
|
Loading…
x
Reference in New Issue
Block a user