Skip to content

docs: clarify split status and counts #6

docs: clarify split status and counts

docs: clarify split status and counts #6

name: Check Case Duplicates
on:
pull_request:
push:
branches: [main]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for case-insensitive duplicates
run: |
python3 << 'PYTHON'
import sys
import hashlib
from collections import defaultdict
from pathlib import Path
def file_hash(path):
"""计算文件 MD5"""
try:
return hashlib.md5(Path(path).read_bytes()).hexdigest()
except:
return None
# 获取所有文件
import subprocess
result = subprocess.run(['git', 'ls-tree', '-r', 'HEAD', '--name-only'],
capture_output=True, text=True)
files = [f.strip() for f in result.stdout.strip().split('\n') if f.strip()]
# 按小写路径分组
groups = defaultdict(list)
for f in files:
groups[f.lower()].append(f)
# 找出重复的
duplicates = {k: v for k, v in groups.items() if len(v) > 1}
if not duplicates:
print("✅ 没有发现大小写重复的文件")
sys.exit(0)
print(f"⚠️ 发现 {len(duplicates)} 组大小写重复的文件:\n")
has_different_content = False
for lower_path, variants in sorted(duplicates.items()):
hashes = {v: file_hash(v) for v in variants}
unique_hashes = set(h for h in hashes.values() if h)
if len(unique_hashes) == 1:
print(f"📁 {lower_path}")
print(f" 文件: {variants}")
print(f" 状态: 内容相同 (可安全删除重复)")
else:
has_different_content = True
print(f"📁 {lower_path}")
print(f" 文件: {variants}")
print(f" 状态: ⚠️ 内容不同!")
for v, h in hashes.items():
print(f" - {v}: {h[:8]}...")
print()
print("=" * 50)
if has_different_content:
print("❌ 存在内容不同的大小写重复文件,请手动处理")
sys.exit(1)
else:
print("⚠️ 存在大小写重复文件(内容相同),请运行修复 workflow")
sys.exit(1)
PYTHON