fix(update): 修复目录忽略逻辑的前缀匹配误命中问题

isIgnoredPath 和 testIsOptionalFiles 方法使用 str_starts_with 做前缀匹配,
导致 .gitea 被 .git 规则误跳过,.gitignore/.gitattributes 同样受影响。
改为精确目录名匹配: ===  || str_starts_with(,  . '/')
This commit is contained in:
augushong
2026-05-06 20:55:17 +08:00
parent 703ec2df8f
commit 718034a7b4

View File

@@ -347,7 +347,7 @@ class AdminUpdateServiceBase
]; ];
foreach ($optional_files_prefix as $prefix) { foreach ($optional_files_prefix as $prefix) {
if (str_starts_with($file_path, $prefix)) { if ($file_path === $prefix || str_starts_with($file_path, $prefix . '/')) {
return true; return true;
} }
} }
@@ -393,7 +393,7 @@ class AdminUpdateServiceBase
protected function isIgnoredPath(string $path, array $ignore_prefix) protected function isIgnoredPath(string $path, array $ignore_prefix)
{ {
foreach ($ignore_prefix as $prefix) { foreach ($ignore_prefix as $prefix) {
if (str_starts_with($path, $prefix)) { if ($path === $prefix || str_starts_with($path, $prefix . '/')) {
return true; return true;
} }
} }