-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal_fill.py
More file actions
125 lines (84 loc) · 2.74 KB
/
final_fill.py
File metadata and controls
125 lines (84 loc) · 2.74 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
#!/usr/bin/env python3
import os
import random
import subprocess
import datetime
from pathlib import Path
REPO_ROOT = Path(__file__).parent
def get_existing():
result = subprocess.run(
['git', 'log', '--pretty=format:%ad', '--date=short', '--all'],
cwd=REPO_ROOT,
capture_output=True,
text=True
)
dates = set(result.stdout.strip().split('\n'))
return {d for d in dates if d}
def commit(date_str):
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 not files:
return False
f = random.choice(files)
try:
with open(f, 'r', encoding='utf-8', errors='ignore') as fp:
c = fp.read()
with open(f, 'w', encoding='utf-8') as fp:
fp.write(c + "\n# Final update\n")
subprocess.run(['git', 'add', str(f)], cwd=REPO_ROOT)
dt = datetime.datetime.strptime(date_str, '%Y-%m-%d')
dt = dt.replace(hour=random.randint(9,20), minute=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
subprocess.run(['git', 'commit', '-m', 'Update'], cwd=REPO_ROOT, env=env, capture_output=True)
return True
except:
return False
def main():
print("Final fill...\n")
subprocess.run(['git', 'checkout', 'full-contributions'], cwd=REPO_ROOT)
existing = get_existing()
end = datetime.datetime.now().date()
start = end - datetime.timedelta(days=365)
filled = 0
current = start
while current <= end:
ds = current.strftime('%Y-%m-%d')
if ds not in existing:
commit(ds)
filled += 1
current += datetime.timedelta(days=1)
print(f"Filled last {filled} gaps!")
subprocess.run(['git', 'checkout', 'fork-main'], cwd=REPO_ROOT)
subprocess.run(['git', 'merge', 'full-contributions', '--no-edit'], cwd=REPO_ROOT)
print("\n✅ Perfect! 100% or very close! Now push to GitHub!")
if __name__ == "__main__":
main()
# 改进
# 优化性能
# 修复边界情况
# 重构代码
# 优化性能
# 改进错误处理
# 改进错误处理
# 更新文档
# 增强功能
# 添加日志记录
# 更新文档
# 增强功能 - 12
# 更新文档 - 40
# 添加日志记录 - 111
# 优化性能 - 134
# 更新文档 - 147
# 重构代码 - 189
# 修复边界情况 - 228
# 改进错误处理 - 9
# 添加日志记录 - 37
# 重构代码 - 130
# 优化性能 - 313
# 添加日志记录 - 334
# 优化性能 - 375
# 重构代码 - 510
# 补充提交 210