Files
zed/script/github-pr-status
Mohamad Khani b72a46db68
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled
logiguard fork: GPUI xdg-activation keyboard-focus serial fix
Single-commit orphan branch: full zed-industries/zed @ 8c74db0 source tree
with a 3-file patch applied (no upstream history).

Patch (crates/gpui_linux/src/linux/wayland/):
  - serial.rs: add SerialKind::KeyboardEnter
  - client.rs: store wl_keyboard.enter serial; add latest_serial_of()
  - window.rs: activate() uses keyboard-enter serial (Mutter focus gate)

Mutter honors window activation only when the token carries the keyboard-
focus serial from wl_keyboard.enter; GPUI used a stale mouse-press serial.
See docs/tray-window-focus-wayland.md in logiguard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 02:22:17 +03:30

211 lines
6.1 KiB
Python
Executable File

#!/usr/bin/env python3
"""
GitHub PR Analyzer for zed-industries/zed repository
Downloads all PRs and groups them by first assignee with status, open date, and last updated date.
"""
import urllib.request
import urllib.parse
import urllib.error
import json
from datetime import datetime
from collections import defaultdict
import sys
import os
# GitHub API configuration
GITHUB_API_BASE = "https://api.github.com"
REPO_OWNER = "zed-industries"
REPO_NAME = "zed"
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
def make_github_request(url, params=None):
"""Make a request to GitHub API with proper headers and pagination support."""
if params:
url_parts = list(urllib.parse.urlparse(url))
query = dict(urllib.parse.parse_qsl(url_parts[4]))
query.update(params)
url_parts[4] = urllib.parse.urlencode(query)
url = urllib.parse.urlunparse(url_parts)
req = urllib.request.Request(url)
req.add_header("Accept", "application/vnd.github.v3+json")
req.add_header("User-Agent", "GitHub-PR-Analyzer")
if GITHUB_TOKEN:
req.add_header("Authorization", f"token {GITHUB_TOKEN}")
try:
response = urllib.request.urlopen(req)
return response
except urllib.error.URLError as e:
print(f"Error making request to {url}: {e}")
return None
except urllib.error.HTTPError as e:
print(f"HTTP error {e.code} for {url}: {e.reason}")
return None
def fetch_all_prs():
"""Fetch all PRs from the repository using pagination."""
prs = []
page = 1
per_page = 100
print("Fetching PRs from GitHub API...")
while True:
url = f"{GITHUB_API_BASE}/repos/{REPO_OWNER}/{REPO_NAME}/pulls"
params = {
"state": "open",
"sort": "updated",
"direction": "desc",
"per_page": per_page,
"page": page
}
response = make_github_request(url, params)
if not response:
break
try:
data = response.read().decode('utf-8')
page_prs = json.loads(data)
except (json.JSONDecodeError, UnicodeDecodeError) as e:
print(f"Error parsing response: {e}")
break
if not page_prs:
break
prs.extend(page_prs)
print(f"Fetched page {page}: {len(page_prs)} PRs (Total: {len(prs)})")
# Check if we have more pages
link_header = response.getheader('Link', '')
if 'rel="next"' not in link_header:
break
page += 1
print(f"Total PRs fetched: {len(prs)}")
return prs
def format_date_as_days_ago(date_string):
"""Format ISO date string as 'X days ago'."""
if not date_string:
return "N/A days ago"
try:
dt = datetime.fromisoformat(date_string.replace('Z', '+00:00'))
now = datetime.now(dt.tzinfo)
days_diff = (now - dt).days
if days_diff == 0:
return "today"
elif days_diff == 1:
return "1 day ago"
else:
return f"{days_diff} days ago"
except:
return "N/A days ago"
def get_first_assignee(pr):
"""Get the first assignee from a PR, or return 'Unassigned' if none."""
assignees = pr.get('assignees', [])
if assignees:
return assignees[0].get('login', 'Unknown')
return 'Unassigned'
def get_pr_status(pr):
"""Determine if PR is draft or ready for review."""
if pr.get('draft', False):
return "Draft"
return "Ready"
def analyze_prs(prs):
"""Group PRs by first assignee and organize the data."""
grouped_prs = defaultdict(list)
for pr in prs:
assignee = get_first_assignee(pr)
pr_info = {
'number': pr['number'],
'title': pr['title'],
'status': get_pr_status(pr),
'state': pr['state'],
'created_at': format_date_as_days_ago(pr['created_at']),
'updated_at': format_date_as_days_ago(pr['updated_at']),
'updated_at_raw': pr['updated_at'],
'url': pr['html_url'],
'author': pr['user']['login']
}
grouped_prs[assignee].append(pr_info)
# Sort PRs within each group by update date (newest first)
for assignee in grouped_prs:
grouped_prs[assignee].sort(key=lambda x: x['updated_at_raw'], reverse=True)
return dict(grouped_prs)
def print_pr_report(grouped_prs):
"""Print formatted report of PRs grouped by assignee."""
print(f"OPEN PR REPORT FOR {REPO_OWNER}/{REPO_NAME}")
print()
# Sort assignees alphabetically, but put 'Unassigned' last
assignees = sorted(grouped_prs.keys())
if 'Unassigned' in assignees:
assignees.remove('Unassigned')
assignees.append('Unassigned')
total_prs = sum(len(prs) for prs in grouped_prs.values())
print(f"Total Open PRs: {total_prs}")
print()
for assignee in assignees:
prs = grouped_prs[assignee]
assignee_display = f"@{assignee}" if assignee != 'Unassigned' else assignee
print(f"assigned to {assignee_display} ({len(prs)} PRs):")
for pr in prs:
print(f"- {pr['author']}: [{pr['title']}]({pr['url']}) opened:{pr['created_at']} updated:{pr['updated_at']}")
print()
def save_json_report(grouped_prs, filename="pr_report.json"):
"""Save the PR data to a JSON file."""
try:
with open(filename, 'w') as f:
json.dump(grouped_prs, f, indent=2)
print(f"📄 Report saved to {filename}")
except Exception as e:
print(f"Error saving JSON report: {e}")
def main():
"""Main function to orchestrate the PR analysis."""
print("GitHub PR Analyzer")
print("==================")
if not GITHUB_TOKEN:
print("⚠️ Warning: GITHUB_TOKEN not set. You may hit rate limits.")
print(" Set GITHUB_TOKEN environment variable for authenticated requests.")
print()
# Fetch all PRs
prs = fetch_all_prs()
if not prs:
print("❌ Failed to fetch PRs. Please check your connection and try again.")
sys.exit(1)
# Analyze and group PRs
grouped_prs = analyze_prs(prs)
# Print report
print_pr_report(grouped_prs)
if __name__ == "__main__":
main()