Skip to content

Commit c4ced24

Browse files
authored
Merge pull request #49 from LetMeFly666/autoPr
newSolution.py autoPR
2 parents 06acca2 + a47a12b commit c4ced24

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

newSolution.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
Author: LetMeFly
33
Date: 2022-07-03 11:21:14
44
LastEditors: LetMeFly
5-
LastEditTime: 2023-08-13 07:49:50
5+
LastEditTime: 2023-10-20 11:59:02
66
Command: python newSolution.py 102. 二叉树的层序遍历
77
What's more: 当前仅支持数字开头的题目
88
'''
9+
import os
910
import sys
1011
import time
1112
from urllib.parse import quote
@@ -70,6 +71,12 @@ def refreshPublistTime(solution: str) -> solution:
7071
solutionName = "Solutions/LeetCode {0:04d}.{1}.md".format(num, title)
7172
with open(solutionName, "x", encoding="utf-8") as f:
7273
f.write(solution)
74+
75+
# 认领issue
76+
os.system(f'git checkout -b {num}')
77+
issueCreateResult = os.popen(f'gh issue create -t "Add 1 more problem of {num}"').read()
78+
issueNum = int(issueCreateResult.split('\n')[0].split('/')[-1])
79+
7380
print("请编辑题解: “{0}”,注意不要更改文件前5行".format(solutionName))
7481

7582
print("请去掉可能的由其他插件自动生成的头部注释信息,并保存你所编辑的题解")
@@ -145,3 +152,12 @@ def getProblemUrl():
145152
print(readme)
146153
with open("README.md", "w", encoding="utf-8") as f:
147154
f.write(readme)
155+
156+
# commit push pr merge delete-branch
157+
os.system('git add .')
158+
os.system(f'git commit -m "添加了问题“{num}.{title}”的代码和题解"')
159+
os.system(f'git push --set-upstream origin {num}')
160+
prResult = os.popen(f'gh pr create -t "添加了问题“{num}.{title}”的代码和题解" -b "By newSolution.py using GH | close: #{issueNum}"').read()
161+
print(prResult)
162+
prNumber = int(prResult.split('/')[-1])
163+
os.system(f'gh pr merge {prNumber} -m -d')

0 commit comments

Comments
 (0)