目标:检测项目内部是否存在可合并的重复模块
# 将项目自身作为目标和候选
gh-sim detect -t ./my-project -c ./my-project -l python --threshold 80目标:检测某 fork 是否直接复制了原项目代码
# 建立原项目指纹库
gh-sim db init
gh-sim db add -p https://github.com/original/project
# 检测 fork 项目
gh-sim plagiarism -t https://github.com/fork/project --db ./fingerprint_db.sqlite目标:同时检测 Python + JavaScript 代码
gh-sim detect -t ./fullstack-project \
-c https://github.com/other/fullstack \
-l python -l javascript \
--threshold 70目标:一个目标项目对比多个候选
gh-sim detect -t ./my-project \
-c https://github.com/cand1/repo \
https://github.com/cand2/repo \
https://github.com/cand3/repo \
--checkpoint cp.json目标:在 PR 中自动检测代码相似度
# 在 CI 脚本中
gh-sim detect \
-t ./changed-files \
-c ./main-branch-code \
--threshold 90 \
--format json \
--output ./similarity-report.json
# 检查是否有高相似度匹配
python -c "
import json, sys
with open('./similarity-report.json') as f:
data = json.load(f)
high = [r for r in data if r.get('similarity', 0) > 90]
if high:
print(f'WARNING: {len(high)} high-similarity matches found')
sys.exit(1)
"目标:将指纹库从开发环境导出到生产环境
# 开发环境
gh-sim db list # 查看项目列表
cp ./fingerprint_db.sqlite ./export/
# 生产环境
cp ./export/fingerprint_db.sqlite ./
gh-sim db stats # 验证严格模式(高精度,少量匹配):
gh-sim detect -t ./project -c ./candidate \
-l python --threshold 85 --granularity function宽松模式(低精度,大量匹配):
gh-sim detect -t ./project -c ./candidate \
-l python --threshold 50 --granularity file