-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport_issues.py
More file actions
69 lines (55 loc) · 2.19 KB
/
import_issues.py
File metadata and controls
69 lines (55 loc) · 2.19 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
import csv
import os
import shutil
import subprocess
import sys
from pathlib import Path
# --- CONFIG ---
REPO = "https://github.com/nitestryker/SecureCrypto-PythonBridge" # <-- change this
CSV_PATH = "github_issues.csv" # or absolute path
def find_gh() -> str:
"""Return full path to gh.exe, or raise a clear error."""
gh_path = shutil.which("gh")
if gh_path:
return gh_path
# Common install locations on Windows
candidates = [
r"C:\Program Files\GitHub CLI\gh.exe",
r"C:\Users\%USERNAME%\AppData\Local\Programs\GitHub CLI\gh.exe",
]
for c in candidates:
resolved = os.path.expandvars(c)
if Path(resolved).exists():
return resolved
raise FileNotFoundError(
"Could not find GitHub CLI (gh.exe). Make sure it's installed and in PATH, "
"or update the candidates list in this script. "
"After installing via winget, you may need to add its folder to PATH and open a NEW terminal."
)
def main():
gh = find_gh()
csv_file = Path(CSV_PATH)
if not csv_file.exists():
print(f"CSV not found: {csv_file.resolve()}", file=sys.stderr)
sys.exit(1)
with csv_file.open(newline="", encoding="utf-8") as f:
reader = csv.DictReader(f)
for i, row in enumerate(reader, start=1):
title = (row.get("Title") or "").strip()
body = (row.get("Body") or "").strip()
labels_raw = (row.get("Labels") or "").strip()
if not title:
print(f"[skip] Row {i}: missing Title")
continue
# Allow comma or semicolon separated labels
labels_parts = [x.strip() for x in labels_raw.replace(";", ",").split(",") if x.strip()]
# gh accepts multiple --label flags; add one per label
label_flags = []
for lab in labels_parts:
label_flags += ["--label", lab]
cmd = [gh, "issue", "create", "--repo", REPO, "--title", title, "--body", body] + label_flags
print(f"[{i}] Creating issue: {title}")
subprocess.run(cmd, check=True)
print("Done. All issues created.")
if __name__ == "__main__":
main()