zen-gitsync 2.11.6 → 2.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/ui/public/assets/index-Ce26lMsG.css +1 -0
- package/src/ui/public/assets/index-DWV3mQ48.js +108 -0
- package/src/ui/public/assets/{vendor-BSAE54oX.js → vendor-BtihdyTS.js} +240 -233
- package/src/ui/public/assets/vendor-CeElb63i.css +1 -0
- package/src/ui/public/index.html +4 -4
- package/src/ui/server/routes/git/stash.js +57 -0
- package/src/ui/server/routes/gitOps.js +18 -0
- package/src/ui/public/assets/index-B2M28SkT.js +0 -108
- package/src/ui/public/assets/index-VYWy-YNd.css +0 -1
- package/src/ui/public/assets/vendor-COoKXBNX.css +0 -1
package/src/ui/public/index.html
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
11
11
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
12
12
|
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-
|
|
15
|
-
<link rel="stylesheet" crossorigin href="/assets/vendor-
|
|
16
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-DWV3mQ48.js"></script>
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-BtihdyTS.js">
|
|
15
|
+
<link rel="stylesheet" crossorigin href="/assets/vendor-CeElb63i.css">
|
|
16
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Ce26lMsG.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<div id="app"></div>
|
|
@@ -478,4 +478,61 @@ export function registerGitStashRoutes({ app, execGitCommand, configManager }) {
|
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
480
|
});
|
|
481
|
+
|
|
482
|
+
// 获取stash中特定文件的完整内容对比(原始 vs 储藏后)
|
|
483
|
+
app.get('/api/stash-file-compare', async (req, res) => {
|
|
484
|
+
try {
|
|
485
|
+
const { stashId, file } = req.query;
|
|
486
|
+
|
|
487
|
+
if (!stashId || !file) {
|
|
488
|
+
return res.status(400).json({ success: false, error: '缺少必要参数' });
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// 解析父提交哈希
|
|
492
|
+
const { stdout: parentsLine } = await execGitCommand(`git rev-list --parents -n 1 ${stashId}`, { log: false });
|
|
493
|
+
const hashes = parentsLine.trim().split(/\s+/).filter(Boolean);
|
|
494
|
+
const stashCommit = hashes[0] || '';
|
|
495
|
+
const parent1 = hashes[1] || '';
|
|
496
|
+
const parent3 = hashes[3] || '';
|
|
497
|
+
|
|
498
|
+
// 检查是否为未跟踪文件(来自第三父)
|
|
499
|
+
let isFromThirdParent = false;
|
|
500
|
+
if (parent3) {
|
|
501
|
+
try {
|
|
502
|
+
await execGitCommand(`git cat-file -e ${parent3}:"${file}"`, { log: false });
|
|
503
|
+
isFromThirdParent = true;
|
|
504
|
+
} catch (_) {
|
|
505
|
+
isFromThirdParent = false;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// 获取原始内容(储藏前,来自 parent1)
|
|
510
|
+
let original = '';
|
|
511
|
+
if (!isFromThirdParent && parent1) {
|
|
512
|
+
try {
|
|
513
|
+
const { stdout: origOut } = await execGitCommand(`git show ${parent1}:"${file}"`, { log: false });
|
|
514
|
+
original = origOut ?? '';
|
|
515
|
+
} catch (_) {
|
|
516
|
+
original = ''; // 文件在储藏前不存在
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// 获取储藏后的内容
|
|
521
|
+
let modified = '';
|
|
522
|
+
const modRef = isFromThirdParent ? parent3 : stashCommit;
|
|
523
|
+
if (modRef) {
|
|
524
|
+
try {
|
|
525
|
+
const { stdout: modOut } = await execGitCommand(`git show ${modRef}:"${file}"`, { log: false });
|
|
526
|
+
modified = modOut ?? '';
|
|
527
|
+
} catch (_) {
|
|
528
|
+
modified = ''; // 文件已被删除
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
res.json({ success: true, original, modified });
|
|
533
|
+
} catch (error) {
|
|
534
|
+
console.error('获取stash文件对比失败:', error);
|
|
535
|
+
res.status(500).json({ success: false, error: `获取stash文件对比失败: ${error.message}` });
|
|
536
|
+
}
|
|
537
|
+
});
|
|
481
538
|
}
|
|
@@ -1021,6 +1021,24 @@ export function registerGitOpsRoutes({
|
|
|
1021
1021
|
}
|
|
1022
1022
|
});
|
|
1023
1023
|
|
|
1024
|
+
// 添加远程仓库的API
|
|
1025
|
+
app.post('/api/add-remote', express.json(), async (req, res) => {
|
|
1026
|
+
try {
|
|
1027
|
+
if (!getIsGitRepo()) {
|
|
1028
|
+
return res.json({ success: false, error: '当前目录不是Git仓库' });
|
|
1029
|
+
}
|
|
1030
|
+
const { name = 'origin', url } = req.body;
|
|
1031
|
+
if (!url || !url.trim()) {
|
|
1032
|
+
return res.json({ success: false, error: '远程仓库地址不能为空' });
|
|
1033
|
+
}
|
|
1034
|
+
await execGitCommand(`git remote add ${name} ${url.trim()}`);
|
|
1035
|
+
res.json({ success: true });
|
|
1036
|
+
} catch (error) {
|
|
1037
|
+
console.error('添加远程仓库失败:', error);
|
|
1038
|
+
res.json({ success: false, error: error.message || '添加远程仓库失败' });
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1024
1042
|
// 获取远程仓库URL的API
|
|
1025
1043
|
app.get('/api/remote-url', async (req, res) => {
|
|
1026
1044
|
try {
|