diff --git a/_归档/_待删_20261022/staging/运行批次/parallel_sources/qoder_2025_2026_bulk_source_hunt_20260927/logs/repo_mirrors/Laz8Noy__kaoyan408-share b/_归档/_待删_20261022/staging/运行批次/parallel_sources/qoder_2025_2026_bulk_source_hunt_20260927/logs/repo_mirrors/Laz8Noy__kaoyan408-share deleted file mode 160000 index baf124bde..000000000 --- a/_归档/_待删_20261022/staging/运行批次/parallel_sources/qoder_2025_2026_bulk_source_hunt_20260927/logs/repo_mirrors/Laz8Noy__kaoyan408-share +++ /dev/null @@ -1 +0,0 @@ -Subproject commit baf124bdecd9f725791404e58dd7d03d1cd1da79 diff --git a/_归档/_待删_20261022/staging/运行批次/parallel_sources/qoder_2025_2026_bulk_source_hunt_20260927/logs/repo_mirrors/zhwen2703-hash__kaoyan-recommendation-platform b/_归档/_待删_20261022/staging/运行批次/parallel_sources/qoder_2025_2026_bulk_source_hunt_20260927/logs/repo_mirrors/zhwen2703-hash__kaoyan-recommendation-platform deleted file mode 160000 index bf7a9c69f..000000000 --- a/_归档/_待删_20261022/staging/运行批次/parallel_sources/qoder_2025_2026_bulk_source_hunt_20260927/logs/repo_mirrors/zhwen2703-hash__kaoyan-recommendation-platform +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bf7a9c69fe012e216cc8b79ff7eef120b304d67d diff --git a/运行暂存/git_flatten_submodules.py b/运行暂存/git_flatten_submodules.py new file mode 100644 index 000000000..35d18a932 --- /dev/null +++ b/运行暂存/git_flatten_submodules.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +"""把两个被当成 submodule 的目录还原成普通目录,让内容真正进仓库。 + +它们在 _归档/_待删_20261022/.../logs/repo_mirrors/ 下,是别人仓库的 mirror clone, +git 只记了个 gitlink,不删内部 .git 的话内容永远进不去。 +""" +import os +import shutil +import subprocess + +ROOT = r'D:\择校' +BASE = os.path.join(ROOT, '_归档', '_待删_20261022', 'staging', '运行批次', 'parallel_sources', + 'qoder_2025_2026_bulk_source_hunt_20260927', 'logs', 'repo_mirrors') +TARGETS = ['Laz8Noy__kaoyan408-share', 'zhwen2703-hash__kaoyan-recommendation-platform'] + + +def run(args): + r = subprocess.run(args, cwd=ROOT, capture_output=True) + return r.returncode, (r.stdout + r.stderr).decode('utf-8', 'replace') + + +for name in TARGETS: + p = os.path.join(BASE, name) + g = os.path.join(p, '.git') + if not os.path.isdir(p): + print('%s 不存在,跳过' % name) + continue + size = 0 + for root, dirs, files in os.walk(p): + for f in files: + try: + size += os.path.getsize(os.path.join(root, f)) + except OSError: + pass + print('%s:%.1f MB' % (name, size / 1048576)) + if os.path.isdir(g): + shutil.rmtree(g, ignore_errors=True) + print(' 已删除内部 .git') + +code, out = run(['git', 'rm', '--cached', '-q', '--ignore-unmatch', '-r', '--'] + + [os.path.relpath(os.path.join(BASE, n), ROOT).replace('\\', '/') for n in TARGETS]) +print('rm --cached exit=%d' % code) + +code, out = run(['git', 'add', '-A']) +print('add exit=%d' % code) +if code != 0: + print(out[-800:]) +code, out = run(['git', 'diff', '--cached', '--shortstat']) +print('暂存:%s' % out.strip())