mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
feat(update): 冲突策略参数替代交互确认
This commit is contained in:
@@ -268,9 +268,32 @@ class AdminUpdateServiceBase
|
||||
}
|
||||
|
||||
if (!empty($optional_update_waring_files)) {
|
||||
$strategy = $this->optionalConflict ?: null; // empty string → null
|
||||
if ($this->dryRun) {
|
||||
$need_process_files = array_merge($need_process_files, $optional_update_waring_files);
|
||||
if ($strategy === null) {
|
||||
// 未传参数:保持现有 dry-run 行为(合并所有冲突文件)
|
||||
$need_process_files = array_merge($need_process_files, $optional_update_waring_files);
|
||||
} else {
|
||||
// 显式传了策略:按策略决定
|
||||
$effective = ($strategy === 'ask') ? 'skip' : $strategy;
|
||||
if ($effective === 'overwrite') {
|
||||
$need_process_files = array_merge($need_process_files, $optional_update_waring_files);
|
||||
} else {
|
||||
// skip: 记录被跳过的文件(供输出增强使用)
|
||||
$this->skippedConflictFiles = array_merge(
|
||||
$this->skippedConflictFiles,
|
||||
array_map(fn($t) => ['type' => $t, 'category' => 'optional'], $optional_update_waring_files)
|
||||
);
|
||||
}
|
||||
}
|
||||
} elseif ($strategy !== null && $strategy !== 'ask') {
|
||||
// 显式指定了非 ask 策略,静默处理
|
||||
if ($strategy === 'overwrite') {
|
||||
$need_process_files = array_merge($need_process_files, $optional_update_waring_files);
|
||||
}
|
||||
// skip: 不加入
|
||||
} else {
|
||||
// null 或 ask: 走原有交互确认(完全保持现有行为)
|
||||
foreach ($optional_update_waring_files as $file_path => $type) {
|
||||
$output->writeln($file_path . ' ' . $type);
|
||||
}
|
||||
@@ -287,9 +310,29 @@ class AdminUpdateServiceBase
|
||||
}
|
||||
|
||||
if (!empty($force_update_waring_files)) {
|
||||
$strategy = $this->forceConflict ?: null; // empty string → null
|
||||
if ($this->dryRun) {
|
||||
$need_process_files = array_merge($need_process_files, $force_update_waring_files);
|
||||
if ($strategy === null) {
|
||||
// 未传参数:保持现有 dry-run 行为(合并所有冲突文件)
|
||||
$need_process_files = array_merge($need_process_files, $force_update_waring_files);
|
||||
} else {
|
||||
$effective = ($strategy === 'ask') ? 'overwrite' : $strategy;
|
||||
if ($effective === 'overwrite') {
|
||||
$need_process_files = array_merge($need_process_files, $force_update_waring_files);
|
||||
} else {
|
||||
// skip: 记录被跳过的文件
|
||||
$this->skippedConflictFiles = array_merge(
|
||||
$this->skippedConflictFiles,
|
||||
array_map(fn($t) => ['type' => $t, 'category' => 'force'], $force_update_waring_files)
|
||||
);
|
||||
}
|
||||
}
|
||||
} elseif ($strategy !== null && $strategy !== 'ask') {
|
||||
if ($strategy === 'overwrite') {
|
||||
$need_process_files = array_merge($need_process_files, $force_update_waring_files);
|
||||
}
|
||||
} else {
|
||||
// null 或 ask: 走原有交互确认
|
||||
foreach ($force_update_waring_files as $file_path => $type) {
|
||||
$output->writeln($file_path . ' ' . $type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user