-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfill_more.py
More file actions
152 lines (104 loc) · 4.32 KB
/
Copy pathfill_more.py
File metadata and controls
152 lines (104 loc) · 4.32 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
#!/usr/bin/env python3
import os
import random
import subprocess
import datetime
from pathlib import Path
REPO_ROOT = Path(__file__).parent
END_DATE = datetime.datetime.now()
def main():
print("=== Adding More Commits to Fill the Graph ===\n")
# 切换到分支
subprocess.run(['git', 'checkout', 'full-contributions'], cwd=REPO_ROOT)
commits_created = 0
# 补充更多提交
print("Adding more commits...\n")
for day_offset in range(365):
current_date = END_DATE - datetime.timedelta(days=day_offset)
# 更高的概率生成提交
if random.random() < 0.9:
num_commits = random.randint(1, 5)
for _ in range(num_commits):
# 修改文件
files = list(REPO_ROOT.glob('**/*.py')) + list(REPO_ROOT.glob('**/*.md'))
files = [f for f in files if '__pycache__' not in str(f) and '.git' not in str(f)]
if files:
f = random.choice(files)
try:
with open(f, 'r', encoding='utf-8', errors='ignore') as fp:
content = fp.read()
adds = [
"\n# Update\n",
"\n# Improvement\n",
"\n# Fix\n",
"\n# Enhancement\n",
"\n# Refactor\n"
]
new_content = content + random.choice(adds)
with open(f, 'w', encoding='utf-8') as fp:
fp.write(new_content)
subprocess.run(['git', 'add', str(f)], cwd=REPO_ROOT)
# 时间
h = random.randint(8, 22)
m = random.randint(0, 59)
commit_date = current_date.replace(hour=h, minute=m, second=random.randint(0,59))
git_date = commit_date.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
msgs = [
"Improve module",
"Update code",
"Fix issue",
"Refactor",
"Enhance feature",
"Add docs",
"Optimize",
"Update config"
]
result = subprocess.run(
['git', 'commit', '-m', random.choice(msgs)],
cwd=REPO_ROOT,
env=env,
capture_output=True,
text=True
)
if result.returncode == 0:
commits_created += 1
if commits_created % 50 == 0:
print(f"Added {commits_created} commits...")
except Exception:
pass
print(f"\n✅ Done! Added {commits_created} more commits!")
# 合并到主分支
print("\nMerging to fork-main...")
subprocess.run(['git', 'checkout', 'fork-main'], cwd=REPO_ROOT)
subprocess.run(['git', 'merge', 'full-contributions', '--no-edit'], cwd=REPO_ROOT)
print("\n✅ All done! Now you can push to GitHub!")
if __name__ == "__main__":
main()
# Small fix
# Improvement
# 添加日志记录
# 改进错误处理
# 更新文档
# 改进错误处理
# 增强功能
# 修复边界情况
# 添加日志记录
# 优化性能
# 添加日志记录
# 重构代码
# 修复边界情况
# 添加日志记录 - 26
# 修复边界情况 - 50
# 更新文档 - 57
# 更新文档 - 94
# 重构代码 - 1
# 更新文档 - 62
# 优化性能 - 152
# 优化性能 - 237
# 添加日志记录 - 409
# 优化性能 - 439
# 添加日志记录 - 542
# 补充提交 175