()
| 221 | |
| 222 | |
| 223 | def main(): |
| 224 | parser = argparse.ArgumentParser(description="Fetch all GitHub issues into a JSON file.") |
| 225 | parser.add_argument("--owner", default="bitsandbytes-foundation", help="Repository owner") |
| 226 | parser.add_argument("--repo", default="bitsandbytes", help="Repository name") |
| 227 | parser.add_argument("--open-only", action="store_true", help="Only fetch open issues") |
| 228 | parser.add_argument( |
| 229 | "-o", "--output", default=None, help="Output JSON file path (default: <repo>_issues.json in script dir)" |
| 230 | ) |
| 231 | args = parser.parse_args() |
| 232 | |
| 233 | output_path = args.output or str(Path(__file__).parent / f"{args.repo}_issues.json") |
| 234 | |
| 235 | open_issues = fetch_all_issues(args.owner, args.repo, ["OPEN"]) |
| 236 | print(file=sys.stderr) |
| 237 | |
| 238 | if args.open_only: |
| 239 | closed_issues = [] |
| 240 | else: |
| 241 | closed_issues = fetch_all_issues(args.owner, args.repo, ["CLOSED"]) |
| 242 | print(file=sys.stderr) |
| 243 | |
| 244 | result = { |
| 245 | "repository": f"{args.owner}/{args.repo}", |
| 246 | "fetched_at": datetime.now(timezone.utc).isoformat(), |
| 247 | "open_issues": open_issues, |
| 248 | "open_count": len(open_issues), |
| 249 | "closed_issues": closed_issues, |
| 250 | "closed_count": len(closed_issues), |
| 251 | } |
| 252 | |
| 253 | with open(output_path, "w") as f: |
| 254 | json.dump(result, f, indent=2, ensure_ascii=False) |
| 255 | |
| 256 | print(f"Wrote {len(open_issues)} open + {len(closed_issues)} closed issues to {output_path}", file=sys.stderr) |
| 257 | |
| 258 | |
| 259 | if __name__ == "__main__": |
no test coverage detected