From 379bf64cb6cc6dca029b09359135a38ef31eb231 Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 20 Mar 2025 17:19:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=89=88=E6=9C=AC=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=95=B4=E7=90=86=E4=BD=BF=E7=94=A8=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/common/command/admin/VersionBase.php | 48 +++++++------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/extend/base/common/command/admin/VersionBase.php b/extend/base/common/command/admin/VersionBase.php index 4923656..a8d72ea 100644 --- a/extend/base/common/command/admin/VersionBase.php +++ b/extend/base/common/command/admin/VersionBase.php @@ -25,6 +25,20 @@ class VersionBase extends Command '- 升级权限管理模式', ]; + protected const COMMIT_TYPES = [ + 'feat' => '新功能', + 'fix' => '修复', + 'docs' => '文档', + 'style' => '样式', + 'refactor' => '重构', + 'perf' => '性能优化', + 'test' => '测试', + 'build' => '构建', + 'ci' => '持续集成', + 'chore' => '其他', + 'revert' => '回退', + ]; + protected function configure() { // 指令配置 @@ -127,26 +141,11 @@ class VersionBase extends Command $commits = explode("\n", $commits); - // 定义提交类型 - $types = [ - 'feat' => '新功能', - 'fix' => '修复', - 'docs' => '文档', - 'style' => '样式', - 'refactor' => '重构', - 'perf' => '性能优化', - 'test' => '测试', - 'build' => '构建', - 'ci' => '持续集成', - 'chore' => '其他', - 'revert' => '回退', - ]; - // 按类型分组提交 $groupedCommits = []; foreach ($commits as $commit) { $matched = false; - foreach ($types as $type => $desc) { + foreach (static::COMMIT_TYPES as $type => $desc) { if (preg_match("/^{$type}:/i", $commit)) { $message = preg_replace("/^{$type}:/i", '', $commit); $groupedCommits[$desc][] = trim($message); @@ -227,21 +226,6 @@ class VersionBase extends Command $commits = explode("\n", $commits); - // 定义提交类型 - $types = [ - 'feat' => '新功能', - 'fix' => '修复', - 'docs' => '文档', - 'style' => '样式', - 'refactor' => '重构', - 'perf' => '性能优化', - 'test' => '测试', - 'build' => '构建', - 'ci' => '持续集成', - 'chore' => '其他', - 'revert' => '回退', - ]; - // 按类型分组提交 $groupedCommits = []; foreach ($commits as $commit) { @@ -254,7 +238,7 @@ class VersionBase extends Command $date = $matches[2]; $message = $matches[3]; - foreach ($types as $type => $desc) { + foreach (static::COMMIT_TYPES as $type => $desc) { if (preg_match("/^{$type}:/i", $message)) { $cleanMessage = preg_replace("/^{$type}:/i", '', $message); $groupedCommits[$desc][] = [