-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsync_issues.py
More file actions
70 lines (55 loc) · 2.15 KB
/
Copy pathsync_issues.py
File metadata and controls
70 lines (55 loc) · 2.15 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
import subprocess
import re
import os
def run_command(command):
try:
result = subprocess.run(command, capture_output=True, text=True, check=True, shell=True)
return result.stdout.strip()
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e}")
print(f"Stderr: {e.stderr}")
return None
def parse_md_to_issues(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
issues = []
# Extract Group A (Existing Issues)
group_a = re.findall(r'#### (#\d+ .*?)\n(.*?)(?=\n#### |$)', content, re.DOTALL)
for title, body in group_a:
issues.append({
'title': title.strip(),
'body': body.strip()
})
# Extract Group B (New Issues)
group_b = re.findall(r'(\d+\. \[Feature\].*?)\n(.*?)(?=\n\d+\. |$)', content, re.DOTALL)
if not group_b:
# Try alternative pattern if numbering is different
group_b = re.findall(r'(\d+\. \[.*?\] .*?)\n(.*?)(?=\n\d+\. |$)', content, re.DOTALL)
for title, body in group_b:
issues.append({
'title': title.strip(),
'body': body.strip()
})
return issues
def sync():
md_file = "docs/ISSUE_BACKLOG_DETAIL.md"
if not os.path.exists(md_file):
print(f"File not found: {md_file}")
return
issues = parse_md_to_issues(md_file)
print(f"Found {len(issues)} issues to register.")
for i, issue in enumerate(issues):
title = issue['title']
body = issue['body']
# Clean up title (remove #ID for new issues or keep it for existing)
# gh issue create --title "title" --body "body"
print(f"[{i+1}/{len(issues)}] Creating: {title}")
# We use a temp file for body to avoid shell escaping issues with long text
with open("temp_body.txt", "w", encoding="utf-8") as f:
f.write(body)
cmd = f'gh issue create --title "{title}" --body-file temp_body.txt'
run_command(cmd)
if os.path.exists("temp_body.txt"):
os.remove("temp_body.txt")
if __name__ == "__main__":
sync()