-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete_fix.py
More file actions
174 lines (128 loc) · 4.61 KB
/
complete_fix.py
File metadata and controls
174 lines (128 loc) · 4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env python3
"""
完全重新生成过去365天的提交,确保GitHub贡献图完整显示
"""
import os
import random
import subprocess
import datetime
from pathlib import Path
REPO_ROOT = Path(__file__).parent
def run_git(cmd):
return subprocess.run(cmd, cwd=REPO_ROOT, capture_output=True, text=True)
def create_commit(target_date):
"""在指定日期创建提交"""
files = list(REPO_ROOT.glob('**/*.py')) + list(REPO_ROOT.glob('**/*.md')) + list(REPO_ROOT.glob('**/*.json'))
files = [f for f in files if '__pycache__' not in str(f) and '.git' not in str(f)]
if not files:
return False
f = random.choice(files)
try:
with open(f, 'r', encoding='utf-8', errors='ignore') as fp:
content = fp.read()
# 添加有意义的修改
modifications = [
"\n# 优化性能\n",
"\n# 改进错误处理\n",
"\n# 添加日志记录\n",
"\n# 重构代码\n",
"\n# 更新文档\n",
"\n# 修复边界情况\n",
"\n# 增强功能\n",
"\n# 添加验证\n"
]
new_content = content + random.choice(modifications)
with open(f, 'w', encoding='utf-8') as fp:
fp.write(new_content)
run_git(['git', 'add', str(f)])
# 设置提交时间
dt = datetime.datetime.strptime(target_date, '%Y-%m-%d')
dt = dt.replace(
hour=random.randint(9, 21),
minute=random.randint(0, 59),
second=random.randint(0, 59)
)
git_date = dt.strftime('%a %b %d %H:%M:%S %Y +0000')
env = os.environ.copy()
env['GIT_AUTHOR_DATE'] = git_date
env['GIT_COMMITTER_DATE'] = git_date
env['GIT_AUTHOR_NAME'] = 'norbertm2050'
env['GIT_AUTHOR_EMAIL'] = 'norbertm2050@gmail.com'
env['GIT_COMMITTER_NAME'] = 'norbertm2050'
env['GIT_COMMITTER_EMAIL'] = 'norbertm2050@gmail.com'
messages = [
"优化新闻收集器模块",
"改进股票市场客户端",
"增强通知系统",
"优化筛选器性能",
"修复报告生成器中的错误",
"添加文档",
"重构LLM集成",
"改进邮件发送器",
"更新配置",
"添加验证检查"
]
result = subprocess.run(
['git', 'commit', '-m', random.choice(messages)],
cwd=REPO_ROOT,
env=env,
capture_output=True,
text=True
)
return result.returncode == 0
except:
return False
def main():
print("=== 完全重新生成365天提交 ===\n")
# 创建新分支
run_git(['git', 'checkout', '-b', 'complete-contributions'])
# 计算正确的日期范围:从今天往前推364天
today = datetime.datetime.now().date()
start_date = today - datetime.timedelta(days=364)
print(f"今天: {today}")
print(f"生成范围: {start_date} 到 {today}")
print(f"总共需要: 365 天\n")
commits_created = 0
current = start_date
while current <= today:
date_str = current.strftime('%Y-%m-%d')
# 每个日期创建1-3个提交
num_commits = random.randint(1, 3)
for _ in range(num_commits):
if create_commit(date_str):
commits_created += 1
if (current - start_date).days % 30 == 0:
print(f"进度: {(current - start_date).days}/365 天, 已创建 {commits_created} 个提交")
current += datetime.timedelta(days=1)
print(f"\n✅ 完成!创建了 {commits_created} 个提交")
# 验证
result = run_git(['git', 'log', '--format=%ad', '--date=short'])
dates = set(result.stdout.strip().split('\n'))
print(f"覆盖天数: {len(dates)}/365")
# 推送到GitHub
print("\n推送到GitHub...")
run_git(['git', 'push', '-u', 'fork', 'complete-contributions:main', '--force'])
print("✅ 推送完成!")
print(f"\n🎉 完成!请访问 https://github.com/norbertm2050 查看贡献图")
if __name__ == "__main__":
main()
# 优化性能
# 优化性能
# 添加日志记录
# 修复边界情况
# 更新文档
# 添加验证
# 更新文档
# 增强功能
# 改进错误处理 - 56
# 更新文档 - 178
# 优化性能 - 179
# 更新文档 - 25
# 优化性能 - 107
# 优化性能 - 195
# 改进错误处理 - 230
# 更新文档 - 232
# 添加日志记录 - 288
# 改进错误处理 - 367
# 更新文档 - 587
# 补充提交 91