@hupan56/wlkj 2.4.2 → 2.4.4
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
CHANGED
|
@@ -193,6 +193,12 @@ def do_pull(quiet=False):
|
|
|
193
193
|
print('Already up to date.')
|
|
194
194
|
else:
|
|
195
195
|
print('Pulled latest from team.')
|
|
196
|
+
# 拉到队友的新 PRD → 自动 collect 到 data/docs/prd/ (历史归档)
|
|
197
|
+
try:
|
|
198
|
+
from git_sync import collect_prds
|
|
199
|
+
collect_prds()
|
|
200
|
+
except Exception:
|
|
201
|
+
pass # collect 失败不阻塞 pull
|
|
196
202
|
return 0
|
|
197
203
|
|
|
198
204
|
|
|
@@ -382,6 +388,13 @@ def _do_push_locked(message, dev, skip_eval, skip_secret):
|
|
|
382
388
|
if r.returncode == 0:
|
|
383
389
|
touch_pull_marker()
|
|
384
390
|
print('Synced to team. (attempt {})'.format(attempt))
|
|
391
|
+
# push 成功后, 自动 collect PRD 到 data/docs/prd/ (历史归档)
|
|
392
|
+
# 这样 search_index --prd 能立刻搜到新 PRD, 不用等周五 cron
|
|
393
|
+
try:
|
|
394
|
+
from git_sync import collect_prds
|
|
395
|
+
collect_prds()
|
|
396
|
+
except Exception as e:
|
|
397
|
+
print('[sync] PRD 归档跳过 (不阻塞): ' + str(e)[:80])
|
|
385
398
|
# D2: 检测 PRD 发布并推飞书通知
|
|
386
399
|
_notify_prd_publications(staged_files)
|
|
387
400
|
return 0
|
|
@@ -393,22 +406,44 @@ def _do_push_locked(message, dev, skip_eval, skip_secret):
|
|
|
393
406
|
|
|
394
407
|
|
|
395
408
|
def do_status():
|
|
409
|
+
# 性能优化: 合并 git 调用 (原 5 次 → 2 次)
|
|
410
|
+
# 一次 git status --branch --porcelain 拿到: 分支名 + ahead/behind + dirty 文件
|
|
411
|
+
r = git('status', '--branch', '--porcelain', '--', *SYNC_SCOPES)
|
|
396
412
|
branch = current_branch()
|
|
397
413
|
print('Branch: {}'.format(branch))
|
|
398
414
|
print('Developer: {}'.format(get_developer() or 'NOT SET'))
|
|
399
415
|
|
|
400
416
|
if not has_remote():
|
|
401
417
|
print('Remote: none (local-only mode)')
|
|
418
|
+
# 仍显示 dirty 文件
|
|
419
|
+
dirty = [l for l in r.stdout.strip().splitlines() if l.strip() and not l.startswith('##')]
|
|
420
|
+
if dirty:
|
|
421
|
+
print('未同步的本地产出: {} 个文件'.format(len(dirty)))
|
|
422
|
+
for l in dirty[:10]:
|
|
423
|
+
print(' ' + l)
|
|
402
424
|
return 0
|
|
403
425
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
426
|
+
# 从 status --branch 输出解析 ahead/behind (避免单独 fetch+rev-list)
|
|
427
|
+
for line in r.stdout.splitlines():
|
|
428
|
+
if line.startswith('## ') and '...' in line:
|
|
429
|
+
# 格式: ## master...origin/master [ahead 3, behind 1]
|
|
430
|
+
import re as _re
|
|
431
|
+
ahead_m = _re.search(r'ahead (\d+)', line)
|
|
432
|
+
behind_m = _re.search(r'behind (\d+)', line)
|
|
433
|
+
ahead = ahead_m.group(1) if ahead_m else '0'
|
|
434
|
+
behind = behind_m.group(1) if behind_m else '0'
|
|
435
|
+
print('Ahead (待推送): {}, Behind (待拉取): {}'.format(ahead, behind))
|
|
436
|
+
break
|
|
437
|
+
else:
|
|
438
|
+
# 没解析到 ahead/behind (可能需要 fetch), 回退到 rev-list
|
|
439
|
+
r2 = git('rev-list', '--left-right', '--count', 'origin/{}...HEAD'.format(branch))
|
|
440
|
+
if r2.returncode == 0 and r2.stdout.strip():
|
|
441
|
+
parts = r2.stdout.split()
|
|
442
|
+
if len(parts) == 2:
|
|
443
|
+
behind, ahead = parts
|
|
444
|
+
print('Ahead (待推送): {}, Behind (待拉取): {}'.format(ahead, behind))
|
|
445
|
+
|
|
446
|
+
dirty = [l for l in r.stdout.strip().splitlines() if l.strip() and not l.startswith('##')]
|
|
412
447
|
print('未同步的本地产出: {} 个文件'.format(len(dirty)))
|
|
413
448
|
for l in dirty[:10]:
|
|
414
449
|
print(' ' + l)
|