zen-gitsync 2.11.17 → 2.11.19

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.
@@ -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-DQJOtLRB.js"></script>
14
- <link rel="modulepreload" crossorigin href="/assets/vendor-OgU7advQ.js">
15
- <link rel="stylesheet" crossorigin href="/assets/vendor-CHxHnXYz.css">
16
- <link rel="stylesheet" crossorigin href="/assets/index-Dj1LeHi7.css">
13
+ <script type="module" crossorigin src="/assets/index-JZlboou5.js"></script>
14
+ <link rel="modulepreload" crossorigin href="/assets/vendor-Ih5RdUJO.js">
15
+ <link rel="stylesheet" crossorigin href="/assets/vendor-CKZkoBDj.css">
16
+ <link rel="stylesheet" crossorigin href="/assets/index-DGWy-waR.css">
17
17
  </head>
18
18
  <body>
19
19
  <div id="app"></div>
@@ -507,6 +507,32 @@ export function registerConfigRoutes({
507
507
  }
508
508
  })
509
509
 
510
+ // 置顶自定义命令(移到数组首位)
511
+ app.post('/api/config/pin-custom-command', express.json(), async (req, res) => {
512
+ try {
513
+ const { id } = req.body
514
+
515
+ if (!id) {
516
+ return res.status(400).json({ success: false, error: '缺少命令ID参数' })
517
+ }
518
+
519
+ const config = await configManager.loadConfig()
520
+
521
+ if (Array.isArray(config.customCommands)) {
522
+ const index = config.customCommands.findIndex(cmd => cmd.id === id)
523
+ if (index > 0) {
524
+ const [cmd] = config.customCommands.splice(index, 1)
525
+ config.customCommands.unshift(cmd)
526
+ await configManager.saveConfig(config)
527
+ }
528
+ }
529
+
530
+ res.json({ success: true })
531
+ } catch (error) {
532
+ res.status(500).json({ success: false, error: error.message })
533
+ }
534
+ })
535
+
510
536
  // 更新自定义命令
511
537
  app.post('/api/config/update-custom-command', express.json(), async (req, res) => {
512
538
  try {
@@ -661,13 +687,14 @@ export function registerConfigRoutes({
661
687
  // 保存提交设置
662
688
  app.post('/api/config/save-commit-settings', express.json(), async (req, res) => {
663
689
  try {
664
- const { isStandardCommit, skipHooks, autoQuickPushOnEnter, autoSetDefaultMessage, autoClosePushModal } = req.body
690
+ const { isStandardCommit, skipHooks, autoQuickPushOnEnter, autoSetDefaultMessage, autoClosePushModal, pullBeforePush } = req.body
665
691
  const config = await configManager.loadConfig()
666
692
  if (isStandardCommit !== undefined) config.isStandardCommit = Boolean(isStandardCommit)
667
693
  if (skipHooks !== undefined) config.skipHooks = Boolean(skipHooks)
668
694
  if (autoQuickPushOnEnter !== undefined) config.autoQuickPushOnEnter = Boolean(autoQuickPushOnEnter)
669
695
  if (autoSetDefaultMessage !== undefined) config.autoSetDefaultMessage = Boolean(autoSetDefaultMessage)
670
696
  if (autoClosePushModal !== undefined) config.autoClosePushModal = Boolean(autoClosePushModal)
697
+ if (pullBeforePush !== undefined) config.pullBeforePush = Boolean(pullBeforePush)
671
698
  await configManager.saveConfig(config)
672
699
  res.json({ success: true })
673
700
  } catch (error) {
@@ -1,3 +1,6 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+
1
4
  export function registerStatusRoutes({
2
5
  app,
3
6
  getCommandHistory,
@@ -16,7 +19,33 @@ export function registerStatusRoutes({
16
19
  app.get('/api/status_porcelain', async (req, res) => {
17
20
  try {
18
21
  const { stdout } = await execGitCommand('git status --porcelain --untracked-files=all');
19
- res.json({ status: stdout });
22
+ // 检测是否处于 MERGING 状态(MERGE_HEAD 文件存在)
23
+ let isMergeInProgress = false;
24
+ let mergeMessage = '';
25
+ try {
26
+ const { stdout: mergeHead } = await execGitCommand('git rev-parse -q --verify MERGE_HEAD');
27
+ isMergeInProgress = mergeHead.trim().length > 0;
28
+ if (isMergeInProgress) {
29
+ // 读取 Git 自动生成的合并提交信息
30
+ try {
31
+ const { stdout: gitDir } = await execGitCommand('git rev-parse --git-dir');
32
+ const mergeMsgPath = path.resolve(gitDir.trim(), 'MERGE_MSG');
33
+ const raw = await fs.readFile(mergeMsgPath, 'utf-8');
34
+ // 过滤掉以 # 开头的注释行,取第一个非空行
35
+ mergeMessage = raw
36
+ .split('\n')
37
+ .filter(line => line.trim() && !line.startsWith('#'))
38
+ .join('\n')
39
+ .trim();
40
+ } catch (_) {
41
+ // MERGE_MSG 不存在时忽略
42
+ }
43
+ }
44
+ } catch (_) {
45
+ // MERGE_HEAD 不存在时命令会报错,属正常情况
46
+ isMergeInProgress = false;
47
+ }
48
+ res.json({ status: stdout, isMergeInProgress, mergeMessage });
20
49
  } catch (error) {
21
50
  res.status(500).json({ error: error.message });
22
51
  }