42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
|
|
def push_files_to_github(files_batch, batch_num):
|
|
"""推送一批文件到GitHub"""
|
|
print(f"\n=== Pushing batch {batch_num} ({len(files_batch)} files) ===")
|
|
|
|
for file_info in files_batch:
|
|
filepath = file_info['path']
|
|
print(f" - {filepath}")
|
|
|
|
# 这里我们只是打印,实际推送将由外部脚本完成
|
|
return True
|
|
|
|
def main():
|
|
# 读取JSON文件
|
|
with open('/tmp/files_to_push.json', 'r', encoding='utf-8') as f:
|
|
all_files = json.load(f)
|
|
|
|
print(f"Total files to push: {len(all_files)}")
|
|
|
|
# 分批处理,每批10个文件
|
|
batch_size = 10
|
|
total_batches = (len(all_files) + batch_size - 1) // batch_size
|
|
|
|
for i in range(total_batches):
|
|
start_idx = i * batch_size
|
|
end_idx = min((i + 1) * batch_size, len(all_files))
|
|
batch = all_files[start_idx:end_idx]
|
|
|
|
# 输出批次的JSON
|
|
batch_file = f'/tmp/batch_{i+1}.json'
|
|
with open(batch_file, 'w', encoding='utf-8') as f:
|
|
json.dump(batch, f, ensure_ascii=False, indent=2)
|
|
|
|
print(f"Batch {i+1}/{total_batches}: {len(batch)} files -> {batch_file}")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|