Created
September 17, 2025 07:47
-
-
Save JKamsker/1653a35f1390f75102a402a2de52d42b to your computer and use it in GitHub Desktop.
Github cli repro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import json | |
| import os | |
| import shlex | |
| import subprocess | |
| from datetime import datetime, timedelta, timezone | |
| def run(cmd): | |
| # Explicitly pass the environment, which can solve obscure issues on Windows. | |
| return subprocess.run(cmd, capture_output=True, text=True, check=True, encoding="utf-8", env=os.environ) | |
| # Check repo | |
| repo_cmd = ["gh", "repo", "view", "--json", "owner,name"] | |
| repo_proc = run(repo_cmd) | |
| print(f"Repo: {repo_proc.stdout}") | |
| # Check gh version | |
| version_cmd = ["gh", "--version"] | |
| version_proc = run(version_cmd) | |
| print(f"GH version: {version_proc.stdout}") | |
| # Check auth | |
| auth_cmd = ["gh", "auth", "status"] | |
| try: | |
| auth_proc = run(auth_cmd) | |
| print(f"Auth: {auth_proc.stdout}") | |
| except Exception as e: | |
| print(f"Auth failed: {e}") | |
| cmd = [ | |
| "gh", | |
| "issue", | |
| "list", | |
| "--limit", | |
| "1000", | |
| "--json", | |
| "number,title,updatedAt,labels,url,state", | |
| "--label=jules", | |
| "--state", | |
| "open", | |
| ] | |
| print(f"Running: {shlex.join(cmd)}") | |
| try: | |
| proc = run(cmd) | |
| print(f"STDOUT: {proc.stdout}") | |
| print(f"STDERR: {proc.stderr}") | |
| data = json.loads(proc.stdout or "[]") | |
| except subprocess.CalledProcessError as e: | |
| print(f"Command failed with exit code {e.returncode}") | |
| print(f"STDOUT: {e.stdout}") | |
| print(f"STDERR: {e.stderr}") | |
| data = [] | |
| print(f"Found {len(data)} issues") | |
| now = datetime.now(timezone.utc) | |
| cutoff = now - timedelta(hours=1) | |
| print(f"Now: {now}") | |
| print(f"Cutoff: {cutoff}") | |
| inactive = [] | |
| for it in data: | |
| updated_str = it.get("updatedAt", "") | |
| if not updated_str: | |
| continue | |
| ts_norm = updated_str.replace("Z", "+00:00") | |
| dt = datetime.fromisoformat(ts_norm) | |
| if dt.tzinfo is None: | |
| dt = dt.replace(tzinfo=timezone.utc) | |
| dt = dt.astimezone(timezone.utc) | |
| print(f"Issue {it['number']}: {updated_str} -> {dt} <= {cutoff}? {dt <= cutoff}") | |
| if dt <= cutoff: | |
| inactive.append(it) | |
| print(f"Inactive count: {len(inactive)}") | |
| if inactive: | |
| for it in inactive: | |
| print(f"#{it['number']} | {it['updatedAt']} | {it['url']} | {it['title']}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment