diff --git a/README.md b/README.md index 2d62a1f..c4cbc2a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@
Version 1.1.4
+Version 1.1.5
DeepSeek Harness jailbreak (破甲): every model can jailbreak; swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐ @@ -537,6 +537,10 @@ If nothing is found, set `DSH_BASE`. No files are changed. ## Changelog +### 1.1.5 + +- Manual Update: if `git pull --ff-only` fails, fetch + reset to `origin/master`, then zip overlay. + ### 1.1.4 - Update check reads `package.json` at the GitHub commit SHA, instead of the stale jsDelivr `@master` cache or falling back to the local version. diff --git a/README.zh-CN.md b/README.zh-CN.md index 18d13cb..5e0043d 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -4,7 +4,7 @@
Version 1.1.4
+Version 1.1.5
DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐ @@ -541,6 +541,10 @@ npm 嵌套布局下,审批在 `dsh-user-approval/lib/index.js`,升级逻辑 ## 更新记录 +### 1.1.5 + +- 点「更新」时:git 快进失败会 `fetch + reset`,再不行改用 zip 覆盖,不再整次失败。 + ### 1.1.4 - 检测更新按 GitHub 提交号读 `package.json`,不再误用 jsDelivr `@master` 缓存,也不会在读不到远端版本时显示成「有新版本 1.1.2,当前 1.1.2」。 diff --git a/lib/update.js b/lib/update.js index 91fcc4e..b77da2c 100644 --- a/lib/update.js +++ b/lib/update.js @@ -386,11 +386,35 @@ export function lastUpdateResult() { return lastUpdate; } +function runGit(dir, args, timeout = 20000) { + try { + return execFileSync("git", ["-C", dir, ...args], { + encoding: "utf8", + stdio: ["ignore", "pipe", "pipe"], + windowsHide: true, + timeout, + }); + } catch (e) { + const detail = [e.stderr, e.stdout, e.message].filter(Boolean).join("\n").trim(); + throw new Error(detail || `git ${args.join(" ")}`); + } +} + function gitPull(dir) { - execFileSync("git", ["-C", dir, "pull", "--ff-only", "origin", BRANCH], { - ...HIDDEN, - timeout: 60000, - }); + try { + runGit(dir, ["pull", "--ff-only", "origin", BRANCH], 60000); + return; + } catch (pullErr) { + try { + runGit(dir, ["fetch", "origin", BRANCH], 60000); + runGit(dir, ["reset", "--hard", `origin/${BRANCH}`], 60000); + return; + } catch (resetErr) { + throw new Error( + `git 更新失败(${dir}):${String(resetErr.message || resetErr).slice(0, 240)};${String(pullErr.message || pullErr).slice(0, 160)}`, + ); + } + } } function extractZip(zip, dest) { @@ -443,8 +467,13 @@ export async function applyUpdate(jobs = planUpdates()) { const vias = new Set(); for (const job of jobs) { if (job.kind === "git") { - gitPull(job.dir); - vias.add("git"); + try { + gitPull(job.dir); + vias.add("git"); + continue; + } catch { + zipDirs.push(job.dir); + } continue; } if (job.kind === "dsh") { diff --git a/package.json b/package.json index 9fd2678..8fc4182 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsh-purge", - "version": "1.1.4", + "version": "1.1.5", "description": "DeepSeek Harness 破甲:所有模型都可破甲,不同模型可换不同提示词;默认提示词面向国模「小码酱」。Jailbreak for every model. 求 Star ⭐", "type": "module", "main": "lib/index.js",