zen-gitsync 2.11.18 → 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-De_hyyUb.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-JZlboou5.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/vendor-Ih5RdUJO.js">
15
15
  <link rel="stylesheet" crossorigin href="/assets/vendor-CKZkoBDj.css">
16
- <link rel="stylesheet" crossorigin href="/assets/index-BiJKdrnL.css">
16
+ <link rel="stylesheet" crossorigin href="/assets/index-DGWy-waR.css">
17
17
  </head>
18
18
  <body>
19
19
  <div id="app"></div>
@@ -687,13 +687,14 @@ export function registerConfigRoutes({
687
687
  // 保存提交设置
688
688
  app.post('/api/config/save-commit-settings', express.json(), async (req, res) => {
689
689
  try {
690
- const { isStandardCommit, skipHooks, autoQuickPushOnEnter, autoSetDefaultMessage, autoClosePushModal } = req.body
690
+ const { isStandardCommit, skipHooks, autoQuickPushOnEnter, autoSetDefaultMessage, autoClosePushModal, pullBeforePush } = req.body
691
691
  const config = await configManager.loadConfig()
692
692
  if (isStandardCommit !== undefined) config.isStandardCommit = Boolean(isStandardCommit)
693
693
  if (skipHooks !== undefined) config.skipHooks = Boolean(skipHooks)
694
694
  if (autoQuickPushOnEnter !== undefined) config.autoQuickPushOnEnter = Boolean(autoQuickPushOnEnter)
695
695
  if (autoSetDefaultMessage !== undefined) config.autoSetDefaultMessage = Boolean(autoSetDefaultMessage)
696
696
  if (autoClosePushModal !== undefined) config.autoClosePushModal = Boolean(autoClosePushModal)
697
+ if (pullBeforePush !== undefined) config.pullBeforePush = Boolean(pullBeforePush)
697
698
  await configManager.saveConfig(config)
698
699
  res.json({ success: true })
699
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
  }