feat(sync_standards): default gitattributes to append

This commit is contained in:
csh
2026-01-08 12:17:00 +08:00
parent da0ef2b7a2
commit e97fb00649
6 changed files with 237 additions and 21 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ sh check_doc_links.sh
- 单语言同步(tsl/cpp
- 多语言同步(tsl cpp
- **.gitattributes 同步**
- 默认模式创建 managed block
- 默认模式追加缺失规则
- 保留现有内容
- 更新已存在的 managed block
- **AGENTS.md 处理**
+25 -3
View File
@@ -81,15 +81,15 @@ teardown() {
# .gitattributes 同步测试
# ==============================================
@test ".gitattributes - 默认模式创建 managed block" {
@test ".gitattributes - 默认模式追加缺失规则" {
cd "$TEST_DIR"
[ ! -f ".gitattributes" ]
sh "$SCRIPT_PATH" tsl
[ -f ".gitattributes" ]
grep -q "# BEGIN playbook .gitattributes" .gitattributes
grep -q "# END playbook .gitattributes" .gitattributes
grep -q "Added from playbook .gitattributes" .gitattributes
grep -q "\\*.tsl" .gitattributes
}
@test ".gitattributes - 保留现有内容" {
@@ -111,6 +111,7 @@ teardown() {
# END playbook .gitattributes
EOF
export SYNC_GITATTR_MODE=block
sh "$SCRIPT_PATH" tsl
# 验证 block 已更新(不再包含 "Old content"
@@ -232,6 +233,27 @@ EOF
! grep -q "# Custom content" .gitattributes
}
@test "环境变量 - SYNC_GITATTR_MODE=append 追加缺失规则" {
cd "$TEST_DIR"
echo "# Custom rules only" > .gitattributes
export SYNC_GITATTR_MODE=append
sh "$SCRIPT_PATH" tsl
grep -q "Added from playbook .gitattributes" .gitattributes
grep -q "\\*.tsl" .gitattributes
}
@test "环境变量 - SYNC_GITATTR_MODE=append 无缺失规则不追加" {
cd "$TEST_DIR"
cp "$PLAYBOOK_ROOT/.gitattributes" .gitattributes
export SYNC_GITATTR_MODE=append
sh "$SCRIPT_PATH" tsl
! grep -q "Added from playbook .gitattributes" .gitattributes
}
# ==============================================
# 幂等性测试
# ==============================================