zen-gitsync 2.0.8 → 2.1.0
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/package.json +1 -1
- package/src/ui/client/src/App.vue +12 -10
- package/src/ui/client/src/components/CommitForm.vue +266 -265
- package/src/ui/client/src/components/GitStatus.vue +5 -8
- package/src/ui/client/src/components/LogList.vue +19 -8
- package/src/ui/client/src/stores/configStore.ts +212 -0
- package/src/ui/client/src/stores/gitStore.ts +48 -34
- package/src/ui/client/stats.html +1 -1
- package/src/ui/public/assets/{index-P9BcPWc5.js → index-VigI_HzC.js} +2 -2
- package/src/ui/public/assets/{index-C3BbS3PG.css → index-gLYHlw0f.css} +1 -1
- package/src/ui/public/index.html +2 -2
- package/src/ui/server/index.js +53 -28
package/src/ui/server/index.js
CHANGED
|
@@ -659,7 +659,22 @@ async function startUIServer() {
|
|
|
659
659
|
const { stdout } = await execGitCommand('git pull');
|
|
660
660
|
res.json({ success: true, message: stdout });
|
|
661
661
|
} catch (error) {
|
|
662
|
-
|
|
662
|
+
// 改进错误处理,检查是否需要合并
|
|
663
|
+
const errorMsg = error.message || '';
|
|
664
|
+
const needsMerge = errorMsg.includes('merge') ||
|
|
665
|
+
errorMsg.includes('需要合并') ||
|
|
666
|
+
errorMsg.includes('CONFLICT') ||
|
|
667
|
+
errorMsg.includes('冲突');
|
|
668
|
+
|
|
669
|
+
// 返回更详细的错误信息和标记
|
|
670
|
+
res.status(500).json({
|
|
671
|
+
success: false,
|
|
672
|
+
error: error.message,
|
|
673
|
+
needsMerge: needsMerge,
|
|
674
|
+
// 包含完整的错误输出
|
|
675
|
+
fullError: error.stderr || error.message,
|
|
676
|
+
pullOutput: error.stdout || ''
|
|
677
|
+
});
|
|
663
678
|
}
|
|
664
679
|
});
|
|
665
680
|
|
|
@@ -1322,9 +1337,7 @@ async function startUIServer() {
|
|
|
1322
1337
|
console.log(`初始化文件系统监控器,路径: ${currentDir}`);
|
|
1323
1338
|
|
|
1324
1339
|
// 检查是否是Git仓库
|
|
1325
|
-
|
|
1326
|
-
execGitCommand('git rev-parse --is-inside-work-tree');
|
|
1327
|
-
} catch (error) {
|
|
1340
|
+
if (!isGitRepo) {
|
|
1328
1341
|
console.log('当前目录不是Git仓库,不启动监控');
|
|
1329
1342
|
return;
|
|
1330
1343
|
}
|
|
@@ -1366,6 +1379,17 @@ async function startUIServer() {
|
|
|
1366
1379
|
// 获取并广播Git状态
|
|
1367
1380
|
async function getAndBroadcastStatus() {
|
|
1368
1381
|
try {
|
|
1382
|
+
// 如果不是Git仓库,发送特殊状态
|
|
1383
|
+
if (!isGitRepo) {
|
|
1384
|
+
io.emit('git_status_update', {
|
|
1385
|
+
isGitRepo: false,
|
|
1386
|
+
status: '当前目录不是Git仓库',
|
|
1387
|
+
porcelain: '',
|
|
1388
|
+
timestamp: new Date().toISOString()
|
|
1389
|
+
});
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1369
1393
|
// 获取常规状态
|
|
1370
1394
|
const { stdout: statusOutput } = await execGitCommand('git status');
|
|
1371
1395
|
|
|
@@ -1374,6 +1398,7 @@ async function startUIServer() {
|
|
|
1374
1398
|
|
|
1375
1399
|
// 广播到所有连接的客户端
|
|
1376
1400
|
io.emit('git_status_update', {
|
|
1401
|
+
isGitRepo: true,
|
|
1377
1402
|
status: statusOutput,
|
|
1378
1403
|
porcelain: porcelainOutput,
|
|
1379
1404
|
timestamp: new Date().toISOString()
|
|
@@ -1396,6 +1421,19 @@ async function startUIServer() {
|
|
|
1396
1421
|
}, DEBOUNCE_DELAY);
|
|
1397
1422
|
}
|
|
1398
1423
|
|
|
1424
|
+
// 检查当前目录是否是Git仓库
|
|
1425
|
+
let isGitRepo = false;
|
|
1426
|
+
try {
|
|
1427
|
+
const { stdout } = await execGitCommand('git rev-parse --is-inside-work-tree', { log: false });
|
|
1428
|
+
isGitRepo = stdout.trim() === 'true';
|
|
1429
|
+
} catch (error) {
|
|
1430
|
+
isGitRepo = false;
|
|
1431
|
+
console.log(chalk.yellow('======================================'));
|
|
1432
|
+
console.log(chalk.yellow(` 提示: 当前目录不是Git仓库`));
|
|
1433
|
+
console.log(chalk.yellow(` 目录: ${process.cwd()}`));
|
|
1434
|
+
console.log(chalk.yellow('======================================'));
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1399
1437
|
// 启动服务器
|
|
1400
1438
|
const PORT = 3000;
|
|
1401
1439
|
httpServer.listen(PORT, () => {
|
|
@@ -1403,11 +1441,15 @@ async function startUIServer() {
|
|
|
1403
1441
|
console.log(chalk.green(` Zen GitSync 服务器已启动`));
|
|
1404
1442
|
console.log(chalk.green(` 访问地址: http://localhost:${PORT}`));
|
|
1405
1443
|
console.log(chalk.green(` 启动时间: ${new Date().toLocaleString()}`));
|
|
1444
|
+
if (isGitRepo) {
|
|
1445
|
+
console.log(chalk.green(` 当前目录是Git仓库,文件监控已启动`));
|
|
1446
|
+
// 启动文件监控
|
|
1447
|
+
initFileSystemWatcher();
|
|
1448
|
+
} else {
|
|
1449
|
+
console.log(chalk.yellow(` 当前目录不是Git仓库,文件监控未启动`));
|
|
1450
|
+
}
|
|
1406
1451
|
console.log(chalk.green('======================================'));
|
|
1407
1452
|
|
|
1408
|
-
// 启动文件监控
|
|
1409
|
-
initFileSystemWatcher();
|
|
1410
|
-
|
|
1411
1453
|
open(`http://localhost:${PORT}`);
|
|
1412
1454
|
}).on('error', async (err) => {
|
|
1413
1455
|
if (err.code === 'EADDRINUSE') {
|
|
@@ -1422,36 +1464,19 @@ async function startUIServer() {
|
|
|
1422
1464
|
console.log(chalk.green(` 访问地址: http://localhost:${newPort}`));
|
|
1423
1465
|
console.log(chalk.green(` 启动时间: ${new Date().toLocaleString()}`));
|
|
1424
1466
|
console.log(chalk.green('======================================'));
|
|
1425
|
-
|
|
1426
|
-
// 启动文件监控
|
|
1427
|
-
initFileSystemWatcher();
|
|
1428
|
-
|
|
1429
|
-
open(`http://localhost:${newPort}`);
|
|
1430
1467
|
resolve();
|
|
1431
|
-
}).on('error', (e) => {
|
|
1432
|
-
if (e.code === 'EADDRINUSE') {
|
|
1433
|
-
console.log(`端口 ${newPort} 也被占用,继续尝试...`);
|
|
1434
|
-
newPort++;
|
|
1435
|
-
reject(e);
|
|
1436
|
-
} else {
|
|
1437
|
-
reject(e);
|
|
1438
|
-
}
|
|
1439
1468
|
});
|
|
1440
1469
|
});
|
|
1441
1470
|
break;
|
|
1442
|
-
} catch (
|
|
1443
|
-
|
|
1444
|
-
console.error('无法找到可用端口,请手动指定端口');
|
|
1445
|
-
process.exit(1);
|
|
1446
|
-
}
|
|
1471
|
+
} catch (error) {
|
|
1472
|
+
newPort++;
|
|
1447
1473
|
}
|
|
1448
1474
|
}
|
|
1449
1475
|
} else {
|
|
1450
|
-
console.error('
|
|
1476
|
+
console.error('启动服务器失败:', err);
|
|
1451
1477
|
process.exit(1);
|
|
1452
1478
|
}
|
|
1453
1479
|
});
|
|
1454
1480
|
}
|
|
1455
1481
|
|
|
1456
|
-
export default startUIServer;
|
|
1457
|
-
|
|
1482
|
+
export default startUIServer;
|