zen-gitsync 2.15.10 → 2.15.12
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 +4 -3
- package/src/gitCommit.js +475 -475
- package/src/ui/public/assets/AppVersionBadge-BaXEI9Aq.js +2 -0
- package/src/ui/public/assets/BranchSelector-DJhEF0y9.js +1 -0
- package/src/ui/public/assets/CommitForm-BfpcK-bz.js +6 -0
- package/src/ui/public/assets/ConsoleView-D838O0O6.js +17 -0
- package/src/ui/public/assets/CustomCommandManager-BcCK46df.js +1 -0
- package/src/ui/public/assets/EditorView-DnnqYNGF.js +0 -0
- package/src/ui/public/assets/{FlowExecutionViewer-Dvv2-pUp.js → FlowExecutionViewer-CSlMmcDS.js} +1 -1
- package/src/ui/public/assets/FlowOrchestrationWorkspace-UgHpZ3FR.js +21 -0
- package/src/ui/public/assets/LogList-uUgskwwp.js +7 -0
- package/src/ui/public/assets/MindmapView-CCmFMiHR.js +1 -0
- package/src/ui/public/assets/{MindmapView-Bt2VdyoX.css → MindmapView-KFcJx-i-.css} +1 -1
- package/src/ui/public/assets/MonitorView-BxoqeX70.js +1 -0
- package/src/ui/public/assets/ProjectStartupButton-C3AwivIB.js +1 -0
- package/src/ui/public/assets/{RemoteRepoCard-BbKpAzPj.js → RemoteRepoCard-BbxeVpje.js} +1 -1
- package/src/ui/public/assets/SourceMapView-DKv-Y6t_.js +3 -0
- package/src/ui/public/assets/{SvgIcon-BoP8CWdO.js → SvgIcon-sMM8XFgm.js} +1 -1
- package/src/ui/public/assets/TemplateManager-Dzj8rXVw.js +1 -0
- package/src/ui/public/assets/UserInputNode-BU7Trzq-.js +1 -0
- package/src/ui/public/assets/WorkbenchView-DMoulJCG.css +1 -0
- package/src/ui/public/assets/WorkbenchView-DTgRoOkv.js +12 -0
- package/src/ui/public/assets/{_plugin-vue_export-helper-D9aIxbUC.js → _plugin-vue_export-helper-8ryIYVvs.js} +1 -1
- package/src/ui/public/assets/{configStore-CiAM1jWr.js → configStore-D77uNk8X.js} +1 -1
- package/src/ui/public/assets/element-plus-D8SQiesr.js +17 -0
- package/src/ui/public/assets/element-plus-DB_sOyH_.css +1 -0
- package/src/ui/public/assets/flow-mindmap-BLa-kSA7.js +90 -0
- package/src/ui/public/assets/flow-mindmap-C_aN-n3H.css +1 -0
- package/src/ui/public/assets/index-CpFreGqX.js +23 -0
- package/src/ui/public/assets/index-CytKCnOp.css +1 -0
- package/src/ui/public/assets/{socket-io-z4n873W1.js → socket-io-B1foIbJS.js} +1 -1
- package/src/ui/public/assets/{vendor-SOsdHF7M.js → vendor-B9orL8iU.js} +37 -37
- package/src/ui/public/assets/vendor-Dm_yd-By.css +1 -0
- package/src/ui/public/assets/{vue-flow-D5lw7RxP.js → vue-flow-BY7LODit.js} +1 -1
- package/src/ui/public/favicon.svg +75 -75
- package/src/ui/public/index.html +28 -28
- package/src/ui/public/logo.svg +74 -74
- package/src/ui/server/middleware/requestLogger.js +53 -53
- package/src/ui/server/routes/branchStatus.js +105 -105
- package/src/ui/server/routes/fileOpen.js +309 -309
- package/src/ui/server/routes/fs.js +791 -791
- package/src/ui/server/routes/git/diff.js +426 -426
- package/src/ui/server/routes/git/diffUtils.js +149 -149
- package/src/ui/server/routes/git/stash.js +550 -550
- package/src/ui/server/routes/git/tags.js +176 -176
- package/src/ui/server/routes/git.js +181 -181
- package/src/ui/server/routes/gitOps.js +1211 -1211
- package/src/ui/server/routes/process.js +86 -86
- package/src/ui/server/routes/status.js +67 -67
- package/src/ui/server/utils/createSavePortToFile.js +48 -48
- package/src/ui/server/utils/instanceRegistry.js +282 -282
- package/src/ui/server/utils/startServerOnAvailablePort.js +116 -116
- package/src/utils/index.js +1168 -1168
- package/src/ui/public/assets/AppVersionBadge-ZginY_T5.js +0 -2
- package/src/ui/public/assets/BranchSelector-BD8y_UMH.js +0 -1
- package/src/ui/public/assets/CommitForm-B1DJxyib.js +0 -6
- package/src/ui/public/assets/ConsoleView-EJa9vjMa.js +0 -17
- package/src/ui/public/assets/CustomCommandManager-BRxKf9jl.js +0 -1
- package/src/ui/public/assets/EditorView-DR2O8qKP.js +0 -0
- package/src/ui/public/assets/FlowOrchestrationWorkspace-DzSgBTmq.js +0 -21
- package/src/ui/public/assets/LogList-BEnd3kcT.js +0 -7
- package/src/ui/public/assets/MindmapView-Ds2Qd2ZL.js +0 -1
- package/src/ui/public/assets/MonitorView-B9t-8uJB.js +0 -1
- package/src/ui/public/assets/ProjectStartupButton-CHh6z5Pn.js +0 -1
- package/src/ui/public/assets/SourceMapView-Deai1zNG.js +0 -3
- package/src/ui/public/assets/TemplateManager-Eu4YhYCk.js +0 -1
- package/src/ui/public/assets/UserInputNode-C0GJHtef.js +0 -1
- package/src/ui/public/assets/WorkbenchView-C2xSxJfg.css +0 -1
- package/src/ui/public/assets/WorkbenchView-DUS0hiHf.js +0 -12
- package/src/ui/public/assets/element-plus-DB-NeCl9.js +0 -24
- package/src/ui/public/assets/element-plus-R1nMzM9j.css +0 -1
- package/src/ui/public/assets/flow-mindmap-CI2OSS19.css +0 -1
- package/src/ui/public/assets/flow-mindmap-DrcjupFb.js +0 -90
- package/src/ui/public/assets/index-Dleiy2zi.js +0 -23
- package/src/ui/public/assets/index-DltbTqIJ.css +0 -1
- package/src/ui/public/assets/vendor-CT8e9rs3.css +0 -1
- package/src/ui/server/.claude/codediff.txt +0 -8
package/src/ui/public/logo.svg
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
<svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<defs>
|
|
3
|
-
<radialGradient id="bgGrad" cx="38%" cy="32%" r="70%">
|
|
4
|
-
<stop offset="0%" stop-color="#1e1b4b"/>
|
|
5
|
-
<stop offset="100%" stop-color="#0d0b1e"/>
|
|
6
|
-
</radialGradient>
|
|
7
|
-
<linearGradient id="mainGrad" x1="0%" y1="0%" x2="0%" y2="100%">
|
|
8
|
-
<stop offset="0%" stop-color="#c4b5fd"/>
|
|
9
|
-
<stop offset="100%" stop-color="#7c3aed"/>
|
|
10
|
-
</linearGradient>
|
|
11
|
-
<linearGradient id="featGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
12
|
-
<stop offset="0%" stop-color="#7dd3fc"/>
|
|
13
|
-
<stop offset="100%" stop-color="#0284c7"/>
|
|
14
|
-
</linearGradient>
|
|
15
|
-
<filter id="glow" x="-40%" y="-40%" width="180%" height="180%">
|
|
16
|
-
<feGaussianBlur in="SourceGraphic" stdDeviation="2.5" result="blur"/>
|
|
17
|
-
<feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge>
|
|
18
|
-
</filter>
|
|
19
|
-
<filter id="softGlow" x="-20%" y="-20%" width="140%" height="140%">
|
|
20
|
-
<feGaussianBlur in="SourceGraphic" stdDeviation="1.5" result="blur"/>
|
|
21
|
-
<feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge>
|
|
22
|
-
</filter>
|
|
23
|
-
</defs>
|
|
24
|
-
|
|
25
|
-
<!-- 背景�?-->
|
|
26
|
-
<circle cx="100" cy="100" r="96" fill="url(#bgGrad)"/>
|
|
27
|
-
|
|
28
|
-
<!-- 同步外弧(上半,代表 sync 循环�?-->
|
|
29
|
-
<path d="M 100,20 A 80,80 0 1,1 36,153"
|
|
30
|
-
stroke="rgba(167,139,250,0.18)" stroke-width="4.5" fill="none" stroke-linecap="round"/>
|
|
31
|
-
<!-- 同步外弧(下半) -->
|
|
32
|
-
<path d="M 36,153 A 80,80 0 0,1 164,153"
|
|
33
|
-
stroke="rgba(56,189,248,0.18)" stroke-width="4.5" fill="none" stroke-linecap="round"/>
|
|
34
|
-
<!-- 同步箭头(上�?-->
|
|
35
|
-
<path d="M 91,17 L 100,20 L 96,29"
|
|
36
|
-
stroke="rgba(167,139,250,0.55)" stroke-width="2.5" fill="none"
|
|
37
|
-
stroke-linecap="round" stroke-linejoin="round"/>
|
|
38
|
-
<!-- 同步箭头(下�?-->
|
|
39
|
-
<path d="M 163,145 L 164,154 L 155,151"
|
|
40
|
-
stroke="rgba(56,189,248,0.55)" stroke-width="2.5" fill="none"
|
|
41
|
-
stroke-linecap="round" stroke-linejoin="round"/>
|
|
42
|
-
|
|
43
|
-
<!-- 主分支竖�?-->
|
|
44
|
-
<line x1="76" y1="44" x2="76" y2="156"
|
|
45
|
-
stroke="url(#mainGrad)" stroke-width="5.5" stroke-linecap="round"
|
|
46
|
-
filter="url(#softGlow)"/>
|
|
47
|
-
|
|
48
|
-
<!-- 特性分支曲线(分出�?-->
|
|
49
|
-
<path d="M 76,80 C 98,80 130,96 130,120 L 130,140"
|
|
50
|
-
stroke="url(#featGrad)" stroke-width="4.5" fill="none"
|
|
51
|
-
stroke-linecap="round" filter="url(#softGlow)"/>
|
|
52
|
-
<!-- 特性分支合并回主分�?-->
|
|
53
|
-
<path d="M 130,140 C 130,156 105,159 76,155"
|
|
54
|
-
stroke="url(#featGrad)" stroke-width="4.5" fill="none" stroke-linecap="round"/>
|
|
55
|
-
|
|
56
|
-
<!-- 主分支节�?-->
|
|
57
|
-
<circle cx="76" cy="48" r="11" fill="#13103a" stroke="#c4b5fd" stroke-width="3" filter="url(#glow)"/>
|
|
58
|
-
<circle cx="76" cy="48" r="5" fill="#ddd6fe"/>
|
|
59
|
-
|
|
60
|
-
<circle cx="76" cy="84" r="11" fill="#13103a" stroke="#a78bfa" stroke-width="3"/>
|
|
61
|
-
<circle cx="76" cy="84" r="5" fill="#c4b5fd"/>
|
|
62
|
-
|
|
63
|
-
<circle cx="76" cy="120" r="11" fill="#13103a" stroke="#8b5cf6" stroke-width="3"/>
|
|
64
|
-
<circle cx="76" cy="120" r="5" fill="#a78bfa"/>
|
|
65
|
-
|
|
66
|
-
<circle cx="76" cy="155" r="11" fill="#13103a" stroke="#7c3aed" stroke-width="3" filter="url(#glow)"/>
|
|
67
|
-
<circle cx="76" cy="155" r="5" fill="#8b5cf6"/>
|
|
68
|
-
|
|
69
|
-
<!-- 特性分支节�?-->
|
|
70
|
-
<circle cx="130" cy="115" r="11" fill="#13103a" stroke="#38bdf8" stroke-width="3" filter="url(#glow)"/>
|
|
71
|
-
<circle cx="130" cy="115" r="5" fill="#7dd3fc"/>
|
|
72
|
-
|
|
73
|
-
<circle cx="130" cy="143" r="11" fill="#13103a" stroke="#0ea5e9" stroke-width="3" filter="url(#glow)"/>
|
|
74
|
-
<circle cx="130" cy="143" r="5" fill="#38bdf8"/>
|
|
1
|
+
<svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<defs>
|
|
3
|
+
<radialGradient id="bgGrad" cx="38%" cy="32%" r="70%">
|
|
4
|
+
<stop offset="0%" stop-color="#1e1b4b"/>
|
|
5
|
+
<stop offset="100%" stop-color="#0d0b1e"/>
|
|
6
|
+
</radialGradient>
|
|
7
|
+
<linearGradient id="mainGrad" x1="0%" y1="0%" x2="0%" y2="100%">
|
|
8
|
+
<stop offset="0%" stop-color="#c4b5fd"/>
|
|
9
|
+
<stop offset="100%" stop-color="#7c3aed"/>
|
|
10
|
+
</linearGradient>
|
|
11
|
+
<linearGradient id="featGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
12
|
+
<stop offset="0%" stop-color="#7dd3fc"/>
|
|
13
|
+
<stop offset="100%" stop-color="#0284c7"/>
|
|
14
|
+
</linearGradient>
|
|
15
|
+
<filter id="glow" x="-40%" y="-40%" width="180%" height="180%">
|
|
16
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="2.5" result="blur"/>
|
|
17
|
+
<feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge>
|
|
18
|
+
</filter>
|
|
19
|
+
<filter id="softGlow" x="-20%" y="-20%" width="140%" height="140%">
|
|
20
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="1.5" result="blur"/>
|
|
21
|
+
<feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge>
|
|
22
|
+
</filter>
|
|
23
|
+
</defs>
|
|
24
|
+
|
|
25
|
+
<!-- 背景�?-->
|
|
26
|
+
<circle cx="100" cy="100" r="96" fill="url(#bgGrad)"/>
|
|
27
|
+
|
|
28
|
+
<!-- 同步外弧(上半,代表 sync 循环�?-->
|
|
29
|
+
<path d="M 100,20 A 80,80 0 1,1 36,153"
|
|
30
|
+
stroke="rgba(167,139,250,0.18)" stroke-width="4.5" fill="none" stroke-linecap="round"/>
|
|
31
|
+
<!-- 同步外弧(下半) -->
|
|
32
|
+
<path d="M 36,153 A 80,80 0 0,1 164,153"
|
|
33
|
+
stroke="rgba(56,189,248,0.18)" stroke-width="4.5" fill="none" stroke-linecap="round"/>
|
|
34
|
+
<!-- 同步箭头(上�?-->
|
|
35
|
+
<path d="M 91,17 L 100,20 L 96,29"
|
|
36
|
+
stroke="rgba(167,139,250,0.55)" stroke-width="2.5" fill="none"
|
|
37
|
+
stroke-linecap="round" stroke-linejoin="round"/>
|
|
38
|
+
<!-- 同步箭头(下�?-->
|
|
39
|
+
<path d="M 163,145 L 164,154 L 155,151"
|
|
40
|
+
stroke="rgba(56,189,248,0.55)" stroke-width="2.5" fill="none"
|
|
41
|
+
stroke-linecap="round" stroke-linejoin="round"/>
|
|
42
|
+
|
|
43
|
+
<!-- 主分支竖�?-->
|
|
44
|
+
<line x1="76" y1="44" x2="76" y2="156"
|
|
45
|
+
stroke="url(#mainGrad)" stroke-width="5.5" stroke-linecap="round"
|
|
46
|
+
filter="url(#softGlow)"/>
|
|
47
|
+
|
|
48
|
+
<!-- 特性分支曲线(分出�?-->
|
|
49
|
+
<path d="M 76,80 C 98,80 130,96 130,120 L 130,140"
|
|
50
|
+
stroke="url(#featGrad)" stroke-width="4.5" fill="none"
|
|
51
|
+
stroke-linecap="round" filter="url(#softGlow)"/>
|
|
52
|
+
<!-- 特性分支合并回主分�?-->
|
|
53
|
+
<path d="M 130,140 C 130,156 105,159 76,155"
|
|
54
|
+
stroke="url(#featGrad)" stroke-width="4.5" fill="none" stroke-linecap="round"/>
|
|
55
|
+
|
|
56
|
+
<!-- 主分支节�?-->
|
|
57
|
+
<circle cx="76" cy="48" r="11" fill="#13103a" stroke="#c4b5fd" stroke-width="3" filter="url(#glow)"/>
|
|
58
|
+
<circle cx="76" cy="48" r="5" fill="#ddd6fe"/>
|
|
59
|
+
|
|
60
|
+
<circle cx="76" cy="84" r="11" fill="#13103a" stroke="#a78bfa" stroke-width="3"/>
|
|
61
|
+
<circle cx="76" cy="84" r="5" fill="#c4b5fd"/>
|
|
62
|
+
|
|
63
|
+
<circle cx="76" cy="120" r="11" fill="#13103a" stroke="#8b5cf6" stroke-width="3"/>
|
|
64
|
+
<circle cx="76" cy="120" r="5" fill="#a78bfa"/>
|
|
65
|
+
|
|
66
|
+
<circle cx="76" cy="155" r="11" fill="#13103a" stroke="#7c3aed" stroke-width="3" filter="url(#glow)"/>
|
|
67
|
+
<circle cx="76" cy="155" r="5" fill="#8b5cf6"/>
|
|
68
|
+
|
|
69
|
+
<!-- 特性分支节�?-->
|
|
70
|
+
<circle cx="130" cy="115" r="11" fill="#13103a" stroke="#38bdf8" stroke-width="3" filter="url(#glow)"/>
|
|
71
|
+
<circle cx="130" cy="115" r="5" fill="#7dd3fc"/>
|
|
72
|
+
|
|
73
|
+
<circle cx="130" cy="143" r="11" fill="#13103a" stroke="#0ea5e9" stroke-width="3" filter="url(#glow)"/>
|
|
74
|
+
<circle cx="130" cy="143" r="5" fill="#38bdf8"/>
|
|
75
75
|
</svg>
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
// Copyright 2026 xz333221
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
//
|
|
15
|
-
import logger from '../utils/logger.js'
|
|
16
|
-
|
|
17
|
-
export function createRequestLogger({ chalk }) {
|
|
18
|
-
return (req, res, next) => {
|
|
19
|
-
const startTime = Date.now();
|
|
20
|
-
const requestTime = new Date().toLocaleString('zh-CN', { hour12: false });
|
|
21
|
-
|
|
22
|
-
res.on('finish', () => {
|
|
23
|
-
const duration = Date.now() - startTime;
|
|
24
|
-
const statusCode = res.statusCode;
|
|
25
|
-
|
|
26
|
-
let statusColor = chalk.green;
|
|
27
|
-
if (statusCode >= 400 && statusCode < 500) {
|
|
28
|
-
statusColor = chalk.yellow;
|
|
29
|
-
} else if (statusCode >= 500) {
|
|
30
|
-
statusColor = chalk.red;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let durationColor = chalk.gray;
|
|
34
|
-
if (duration > 1000) {
|
|
35
|
-
durationColor = chalk.red;
|
|
36
|
-
} else if (duration > 500) {
|
|
37
|
-
durationColor = chalk.yellow;
|
|
38
|
-
} else if (duration > 200) {
|
|
39
|
-
durationColor = chalk.cyan;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
logger.info(
|
|
43
|
-
chalk.dim(`[${requestTime}]`),
|
|
44
|
-
chalk.bold(req.method),
|
|
45
|
-
req.url,
|
|
46
|
-
statusColor(`[${statusCode}]`),
|
|
47
|
-
durationColor(`${duration}ms`)
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
next();
|
|
52
|
-
};
|
|
53
|
-
}
|
|
1
|
+
// Copyright 2026 xz333221
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
import logger from '../utils/logger.js'
|
|
16
|
+
|
|
17
|
+
export function createRequestLogger({ chalk }) {
|
|
18
|
+
return (req, res, next) => {
|
|
19
|
+
const startTime = Date.now();
|
|
20
|
+
const requestTime = new Date().toLocaleString('zh-CN', { hour12: false });
|
|
21
|
+
|
|
22
|
+
res.on('finish', () => {
|
|
23
|
+
const duration = Date.now() - startTime;
|
|
24
|
+
const statusCode = res.statusCode;
|
|
25
|
+
|
|
26
|
+
let statusColor = chalk.green;
|
|
27
|
+
if (statusCode >= 400 && statusCode < 500) {
|
|
28
|
+
statusColor = chalk.yellow;
|
|
29
|
+
} else if (statusCode >= 500) {
|
|
30
|
+
statusColor = chalk.red;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let durationColor = chalk.gray;
|
|
34
|
+
if (duration > 1000) {
|
|
35
|
+
durationColor = chalk.red;
|
|
36
|
+
} else if (duration > 500) {
|
|
37
|
+
durationColor = chalk.yellow;
|
|
38
|
+
} else if (duration > 200) {
|
|
39
|
+
durationColor = chalk.cyan;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
logger.info(
|
|
43
|
+
chalk.dim(`[${requestTime}]`),
|
|
44
|
+
chalk.bold(req.method),
|
|
45
|
+
req.url,
|
|
46
|
+
statusColor(`[${statusCode}]`),
|
|
47
|
+
durationColor(`${duration}ms`)
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
next();
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
// Copyright 2026 xz333221
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
//
|
|
15
|
-
import { asyncRoute, HttpError } from '../utils/asyncRoute.js'
|
|
16
|
-
|
|
17
|
-
import logger from '../utils/logger.js'
|
|
18
|
-
|
|
19
|
-
export function registerBranchStatusRoutes({
|
|
20
|
-
app,
|
|
21
|
-
execGitCommand,
|
|
22
|
-
getIsGitRepo,
|
|
23
|
-
getBranchStatusCache,
|
|
24
|
-
setBranchStatusCache,
|
|
25
|
-
getRecentPushStatus,
|
|
26
|
-
setRecentPushStatus
|
|
27
|
-
}) {
|
|
28
|
-
// 获取当前分支 - 直接读取,不缓存(git symbolic-ref 极快,<5ms)
|
|
29
|
-
app.get('/api/branch', asyncRoute(async (req, res) => {
|
|
30
|
-
try {
|
|
31
|
-
const { stdout } = await execGitCommand(['symbolic-ref', '--short', 'HEAD']);
|
|
32
|
-
res.json({ branch: stdout.trim() });
|
|
33
|
-
} catch (error) {
|
|
34
|
-
res.status(500).json({ error: error.message });
|
|
35
|
-
}
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
|
-
// 获取分支与远程的差异状态(领先/落后提交数)
|
|
39
|
-
app.get('/api/branch-status', asyncRoute(async (req, res) => {
|
|
40
|
-
try {
|
|
41
|
-
if (!getIsGitRepo()) {
|
|
42
|
-
return res.json({ hasUpstream: false, ahead: 0, behind: 0 });
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const now = Date.now();
|
|
46
|
-
const forceRefresh = req.query.force === 'true';
|
|
47
|
-
|
|
48
|
-
const recentPushStatus = getRecentPushStatus();
|
|
49
|
-
const branchStatusCache = getBranchStatusCache();
|
|
50
|
-
|
|
51
|
-
// push 后10秒内直接返回同步状态
|
|
52
|
-
if (recentPushStatus.justPushed &&
|
|
53
|
-
(now - recentPushStatus.pushTime) < recentPushStatus.validDuration) {
|
|
54
|
-
logger.info('检测到最近推送过,直接返回同步状态');
|
|
55
|
-
return res.json({
|
|
56
|
-
hasUpstream: true,
|
|
57
|
-
upstreamBranch: branchStatusCache.upstreamBranch || 'origin/main',
|
|
58
|
-
ahead: 0,
|
|
59
|
-
behind: 0
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 5秒缓存分支名,防止短时间内重复执行 git symbolic-ref / git rev-parse
|
|
64
|
-
const branchInfoCacheValid = !forceRefresh &&
|
|
65
|
-
branchStatusCache.currentBranch &&
|
|
66
|
-
branchStatusCache.upstreamBranch &&
|
|
67
|
-
(now - branchStatusCache.lastUpdate) < branchStatusCache.cacheTimeout;
|
|
68
|
-
|
|
69
|
-
let currentBranch, upstreamBranch;
|
|
70
|
-
|
|
71
|
-
if (branchInfoCacheValid) {
|
|
72
|
-
currentBranch = branchStatusCache.currentBranch;
|
|
73
|
-
upstreamBranch = branchStatusCache.upstreamBranch;
|
|
74
|
-
logger.info(`使用5秒缓存的分支名: ${currentBranch} -> ${upstreamBranch}`);
|
|
75
|
-
} else {
|
|
76
|
-
// 直接读取,不再走5分钟长缓存
|
|
77
|
-
const { stdout: branchOut } = await execGitCommand(['symbolic-ref', '--short', 'HEAD']);
|
|
78
|
-
currentBranch = branchOut.trim();
|
|
79
|
-
|
|
80
|
-
const { stdout: upstreamOut } = await execGitCommand(
|
|
81
|
-
['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'],
|
|
82
|
-
{ ignoreError: true }
|
|
83
|
-
);
|
|
84
|
-
upstreamBranch = upstreamOut.trim() || null;
|
|
85
|
-
|
|
86
|
-
if (!upstreamBranch) {
|
|
87
|
-
setBranchStatusCache({ currentBranch: null, upstreamBranch: null, lastUpdate: 0, cacheTimeout: 5000 });
|
|
88
|
-
return res.json({ hasUpstream: false, ahead: 0, behind: 0 });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
setBranchStatusCache({ currentBranch, upstreamBranch, lastUpdate: now, cacheTimeout: 5000 });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const { stdout: aheadBehindOutput } = await execGitCommand(
|
|
95
|
-
['rev-list', '--left-right', '--count', `${currentBranch}...${upstreamBranch}`]
|
|
96
|
-
);
|
|
97
|
-
const [ahead, behind] = aheadBehindOutput.trim().split('\t').map(Number);
|
|
98
|
-
|
|
99
|
-
res.json({ hasUpstream: true, upstreamBranch, ahead, behind });
|
|
100
|
-
} catch (error) {
|
|
101
|
-
logger.error('获取分支状态失败:', error);
|
|
102
|
-
res.status(500).json({ error: error.message });
|
|
103
|
-
}
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
1
|
+
// Copyright 2026 xz333221
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
import { asyncRoute, HttpError } from '../utils/asyncRoute.js'
|
|
16
|
+
|
|
17
|
+
import logger from '../utils/logger.js'
|
|
18
|
+
|
|
19
|
+
export function registerBranchStatusRoutes({
|
|
20
|
+
app,
|
|
21
|
+
execGitCommand,
|
|
22
|
+
getIsGitRepo,
|
|
23
|
+
getBranchStatusCache,
|
|
24
|
+
setBranchStatusCache,
|
|
25
|
+
getRecentPushStatus,
|
|
26
|
+
setRecentPushStatus
|
|
27
|
+
}) {
|
|
28
|
+
// 获取当前分支 - 直接读取,不缓存(git symbolic-ref 极快,<5ms)
|
|
29
|
+
app.get('/api/branch', asyncRoute(async (req, res) => {
|
|
30
|
+
try {
|
|
31
|
+
const { stdout } = await execGitCommand(['symbolic-ref', '--short', 'HEAD']);
|
|
32
|
+
res.json({ branch: stdout.trim() });
|
|
33
|
+
} catch (error) {
|
|
34
|
+
res.status(500).json({ error: error.message });
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
// 获取分支与远程的差异状态(领先/落后提交数)
|
|
39
|
+
app.get('/api/branch-status', asyncRoute(async (req, res) => {
|
|
40
|
+
try {
|
|
41
|
+
if (!getIsGitRepo()) {
|
|
42
|
+
return res.json({ hasUpstream: false, ahead: 0, behind: 0 });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const now = Date.now();
|
|
46
|
+
const forceRefresh = req.query.force === 'true';
|
|
47
|
+
|
|
48
|
+
const recentPushStatus = getRecentPushStatus();
|
|
49
|
+
const branchStatusCache = getBranchStatusCache();
|
|
50
|
+
|
|
51
|
+
// push 后10秒内直接返回同步状态
|
|
52
|
+
if (recentPushStatus.justPushed &&
|
|
53
|
+
(now - recentPushStatus.pushTime) < recentPushStatus.validDuration) {
|
|
54
|
+
logger.info('检测到最近推送过,直接返回同步状态');
|
|
55
|
+
return res.json({
|
|
56
|
+
hasUpstream: true,
|
|
57
|
+
upstreamBranch: branchStatusCache.upstreamBranch || 'origin/main',
|
|
58
|
+
ahead: 0,
|
|
59
|
+
behind: 0
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 5秒缓存分支名,防止短时间内重复执行 git symbolic-ref / git rev-parse
|
|
64
|
+
const branchInfoCacheValid = !forceRefresh &&
|
|
65
|
+
branchStatusCache.currentBranch &&
|
|
66
|
+
branchStatusCache.upstreamBranch &&
|
|
67
|
+
(now - branchStatusCache.lastUpdate) < branchStatusCache.cacheTimeout;
|
|
68
|
+
|
|
69
|
+
let currentBranch, upstreamBranch;
|
|
70
|
+
|
|
71
|
+
if (branchInfoCacheValid) {
|
|
72
|
+
currentBranch = branchStatusCache.currentBranch;
|
|
73
|
+
upstreamBranch = branchStatusCache.upstreamBranch;
|
|
74
|
+
logger.info(`使用5秒缓存的分支名: ${currentBranch} -> ${upstreamBranch}`);
|
|
75
|
+
} else {
|
|
76
|
+
// 直接读取,不再走5分钟长缓存
|
|
77
|
+
const { stdout: branchOut } = await execGitCommand(['symbolic-ref', '--short', 'HEAD']);
|
|
78
|
+
currentBranch = branchOut.trim();
|
|
79
|
+
|
|
80
|
+
const { stdout: upstreamOut } = await execGitCommand(
|
|
81
|
+
['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'],
|
|
82
|
+
{ ignoreError: true }
|
|
83
|
+
);
|
|
84
|
+
upstreamBranch = upstreamOut.trim() || null;
|
|
85
|
+
|
|
86
|
+
if (!upstreamBranch) {
|
|
87
|
+
setBranchStatusCache({ currentBranch: null, upstreamBranch: null, lastUpdate: 0, cacheTimeout: 5000 });
|
|
88
|
+
return res.json({ hasUpstream: false, ahead: 0, behind: 0 });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setBranchStatusCache({ currentBranch, upstreamBranch, lastUpdate: now, cacheTimeout: 5000 });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const { stdout: aheadBehindOutput } = await execGitCommand(
|
|
95
|
+
['rev-list', '--left-right', '--count', `${currentBranch}...${upstreamBranch}`]
|
|
96
|
+
);
|
|
97
|
+
const [ahead, behind] = aheadBehindOutput.trim().split('\t').map(Number);
|
|
98
|
+
|
|
99
|
+
res.json({ hasUpstream: true, upstreamBranch, ahead, behind });
|
|
100
|
+
} catch (error) {
|
|
101
|
+
logger.error('获取分支状态失败:', error);
|
|
102
|
+
res.status(500).json({ error: error.message });
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
105
|
+
}
|