Add all Java source files

This commit is contained in:
H1d3rOne committed 2026-03-05 23:07:37 +08:00
1 parent 165494d98e
commit 3ed8e94723
4 files changed
+161

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
#!/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()
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
import os
import json
import subprocess
import sys
def get_all_files():
"""获取所有需要推送的文件"""
result = subprocess.run(
['find', '.', '-type', 'f', '-name', '*.java'],
capture_output=True,
text=True
)
files = result.stdout.strip().split('\n')
# 过滤掉不需要的文件
files = [f for f in files if f and not f.startswith('./.trae')]
return files
def main():
files = get_all_files()
print(f"Found {len(files)} Java files to push")
for filepath in files:
# 移除开头的 ./
if filepath.startswith('./'):
filepath = filepath[2:]
print(filepath)
if __name__ == '__main__':
main()
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
import os
import json
import subprocess
def read_file(filepath):
"""读取文件内容"""
try:
with open(filepath, 'r', encoding='utf-8') as f:
return f.read()
except Exception as e:
print(f"Error reading {filepath}: {e}")
return None
def main():
# 获取所有Java文件
result = subprocess.run(
['find', 'src', '-type', 'f', '-name', '*.java'],
capture_output=True,
text=True
)
files = result.stdout.strip().split('\n')
files = [f for f in files if f]
print(f"Total files: {len(files)}")
# 创建JSON格式的文件列表
file_list = []
for filepath in files:
content = read_file(filepath)
if content:
file_list.append({
'path': filepath,
'content': content
})
print(f"Prepared: {filepath}")
# 输出JSON
with open('/tmp/files_to_push.json', 'w', encoding='utf-8') as f:
json.dump(file_list, f, ensure_ascii=False, indent=2)
print(f"\nTotal files prepared: {len(file_list)}")
print("Files saved to /tmp/files_to_push.json")
if __name__ == '__main__':
main()
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
import os
import base64
import json
import subprocess
def get_file_content(filepath):
"""读取文件内容并返回"""
try:
with open(filepath, 'r', encoding='utf-8') as f:
return f.read()
except Exception as e:
print(f"Error reading {filepath}: {e}")
return None
def get_all_java_files():
"""获取所有Java文件"""
result = subprocess.run(
['find', 'src', '-name', '*.java', '-type', 'f'],
capture_output=True,
text=True
)
files = result.stdout.strip().split('\n')
return [f for f in files if f]
def main():
java_files = get_all_java_files()
print(f"Found {len(java_files)} Java files")
# 创建文件列表
file_list = []
for filepath in java_files:
content = get_file_content(filepath)
if content:
file_list.append({
'path': filepath,
'content': content
})
print(f"Prepared: {filepath}")
print(f"\nTotal files prepared: {len(file_list)}")
if __name__ == '__main__':
main()