Spaces:
Running
Running
File size: 1,636 Bytes
6940f27 | 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 | import subprocess
import json
import sys
# Ensure UTF-8 output
sys.stdout.reconfigure(encoding='utf-8')
def run_cmd(cmd):
try:
res = subprocess.run(cmd, shell=True, capture_output=True, text=True, encoding='utf-8')
return res.stdout, res.stderr
except Exception as e:
return "", str(e)
def get_open_issues():
out, err = run_cmd("gh issue list --limit 100 --json number,title,labels,assignees")
if not out or not out.strip():
return []
try:
return json.loads(out)
except Exception as e:
return []
def get_issue_comments(number):
out, err = run_cmd(f"gh issue view {number} --json comments")
if not out or not out.strip():
return []
try:
data = json.loads(out)
return data.get("comments", [])
except Exception as e:
return []
issues = get_open_issues()
print(f"Found {len(issues)} open issues.")
for iss in issues:
num = iss["number"]
title = iss["title"]
labels = [l["name"] for l in iss.get("labels", [])]
assignees = [a["login"] for a in iss.get("assignees", [])]
comments = get_issue_comments(num)
# Only print issues that have comments or are recently active
if len(comments) > 0:
print(f"\n# {num} | Title: {title}")
print(f" Labels: {labels}")
print(f" Assignees: {assignees}")
print(f" Comments count: {len(comments)}")
for c in comments:
author = c.get("author", {}).get("login", "unknown")
body = c.get("body", "").replace('\n', ' ').strip()[:140]
print(f" - [{author}]: {body}...")
|