fix: git 快进失败时 reset 或 zip 覆盖,更新不再整次失败

This commit is contained in:
叫我小杨同学 committed 2026-09-18 14:18:35 +08:00
1 parent f11078eb1f
commit bea3877f4d
4 files changed
+46 -9

No files matched your search

+5 -1
View File
@@ -4,7 +4,7 @@
<h1 align="center">dsh-purge</h1>
<p align="center"><strong>Version 1.1.4</strong></p>
<p align="center"><strong>Version 1.1.5</strong></p>
<p align="center">
<em>DeepSeek Harness jailbreak (破甲): every model can jailbreak; swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐</em>
@@ -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.
+5 -1
View File
@@ -4,7 +4,7 @@
<h1 align="center">dsh-purge</h1>
<p align="center"><strong>Version 1.1.4</strong></p>
<p align="center"><strong>Version 1.1.5</strong></p>
<p align="center">
<em>DeepSeek Harness 破甲:让所有模型都能破甲,不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐</em>
@@ -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」。
+35 -6
View File
@@ -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") {
+1 -1
View File
@@ -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",