Fixed various other oversights.

This commit is contained in:
flash 2023-07-15 02:14:39 +00:00
parent c56617e051
commit 69c6b6f2ac
4 changed files with 25 additions and 38 deletions

View file

@ -1,9 +1,6 @@
<?php <?php
namespace Misuzu; namespace Misuzu;
use Misuzu\DB;
use Misuzu\Changelog\ChangelogChange;
$misuzuBypassLockdown = true; $misuzuBypassLockdown = true;
require_once '../misuzu.php'; require_once '../misuzu.php';
@ -12,7 +9,7 @@ function ghcb_strip_prefix(string $line): string {
return trim($findColon === false || $findColon >= 10 ? $line : mb_substr($line, $findColon + 1)); return trim($findColon === false || $findColon >= 10 ? $line : mb_substr($line, $findColon + 1));
} }
function ghcb_changelog_action(string &$line): int { function ghcb_changelog_action(string &$line): string {
$original = trim($line); $original = trim($line);
$line = ghcb_strip_prefix($line); $line = ghcb_strip_prefix($line);
@ -20,17 +17,17 @@ function ghcb_changelog_action(string &$line): int {
if($firstSix === 'revert' if($firstSix === 'revert'
|| $firstSix === 'restor') || $firstSix === 'restor')
return ChangelogChange::ACTION_REVERT; return 'revert';
if($firstSix === 'import') if($firstSix === 'import')
return ChangelogChange::ACTION_IMPORT; return 'import';
$firstThree = mb_strtolower(mb_substr($original, 0, 3)); $firstThree = mb_strtolower(mb_substr($original, 0, 3));
if($firstThree === 'add' if($firstThree === 'add'
|| $firstSix === 'create') || $firstSix === 'create')
return ChangelogChange::ACTION_ADD; return 'add';
if($firstThree === 'fix') if($firstThree === 'fix')
return ChangelogChange::ACTION_FIX; return 'fix';
$firstFour = mb_strtolower(mb_substr($original, 0, 4)); $firstFour = mb_strtolower(mb_substr($original, 0, 4));
$firstEight = mb_strtolower(mb_substr($original, 0, 8)); $firstEight = mb_strtolower(mb_substr($original, 0, 8));
@ -39,9 +36,9 @@ function ghcb_changelog_action(string &$line): int {
|| $firstSix === 'remove' || $firstSix === 'remove'
|| $firstFour === 'nuke' || $firstFour === 'nuke'
|| $firstEight === 'dropkick') || $firstEight === 'dropkick')
return ChangelogChange::ACTION_REMOVE; return 'remove';
return ChangelogChange::ACTION_UPDATE; return 'update';
} }
header('Content-Type: text/plain; charset=utf-8'); header('Content-Type: text/plain; charset=utf-8');

View file

@ -82,23 +82,25 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
$changelog->updateChange($changeInfo, $action, $summary, $body, $updateUserInfo, $userId, $createdAt); $changelog->updateChange($changeInfo, $action, $summary, $body, $updateUserInfo, $userId, $createdAt);
} }
$tCurrent = $changeInfo->getTagIds(); if(!empty($tags)) {
$tApply = $tags; $tCurrent = $changeInfo->getTagIds();
$tRemove = []; $tApply = $tags;
$tRemove = [];
foreach($tCurrent as $tag) foreach($tCurrent as $tag)
if(!in_array($tag, $tApply)) { if(!in_array($tag, $tApply)) {
$tRemove[] = $tag; $tRemove[] = $tag;
$changelog->removeTagFromChange($changeInfo, $tag); $changelog->removeTagFromChange($changeInfo, $tag);
} }
$tCurrent = array_diff($tCurrent, $tRemove); $tCurrent = array_diff($tCurrent, $tRemove);
foreach($tApply as $tag) foreach($tApply as $tag)
if(!in_array($tag, $tCurrent)) { if(!in_array($tag, $tCurrent)) {
$changelog->addTagToChange($changeInfo, $tag); $changelog->addTagToChange($changeInfo, $tag);
$tCurrent[] = $tag; $tCurrent[] = $tag;
} }
}
AuditLog::create( AuditLog::create(
$isNew ? AuditLog::CHANGELOG_ENTRY_CREATE : AuditLog::CHANGELOG_ENTRY_EDIT, $isNew ? AuditLog::CHANGELOG_ENTRY_CREATE : AuditLog::CHANGELOG_ENTRY_EDIT,

View file

@ -1,12 +0,0 @@
<?php
namespace Misuzu\Changelog;
class ChangelogChange {
public const ACTION_UNKNOWN = 0;
public const ACTION_ADD = 1;
public const ACTION_REMOVE = 2;
public const ACTION_UPDATE = 3;
public const ACTION_FIX = 4;
public const ACTION_IMPORT = 5;
public const ACTION_REVERT = 6;
}

View file

@ -46,7 +46,7 @@
<ul class="changelog__change__tags"> <ul class="changelog__change__tags">
{% for tag in change_info.tags %} {% for tag in change_info.tags %}
<li class="changelog__change__tag" title="{{ tag.description }}"> <li class="changelog__change__tag" title="{{ tag.description }}">
<a href="{{ url('changelog-tag', {'tag': tag.id}) }}" class="changelog__change__tag__link"> <a href="{{ url('changelog-index', {'tags': tag.id}) }}" class="changelog__change__tag__link">
{{ tag.name }} {{ tag.name }}
</a> </a>
</li> </li>
@ -60,7 +60,7 @@
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
{% if change_info.hasBody %} {% if change_info.hasBody %}
{{ change_info.parsedBody|raw }} {{ change_info.body|parse_text(2)|raw }}
{% else %} {% else %}
<p>This change has no additional notes.</p> <p>This change has no additional notes.</p>
{% endif %} {% endif %}