|
5 | 5 | """ |
6 | 6 |
|
7 | 7 | import argparse |
| 8 | +import json |
8 | 9 | import os |
9 | 10 | import subprocess |
10 | 11 | import sys |
11 | | -import json |
12 | 12 | from datetime import datetime, timezone |
13 | 13 | from pathlib import Path |
14 | 14 |
|
@@ -187,6 +187,7 @@ def create_removal_pr(repo: str, component: dict, repo_path: Path, dry_run: bool |
187 | 187 | print(f"[DRY RUN] Would create removal PR: {title}") |
188 | 188 | print(f" Branch: {branch_name}") |
189 | 189 | print(f" Removes: {path}") |
| 190 | + print(f" Updates: {Path(path).parent}/README.md (category index)") |
190 | 191 | print(f" Reviewers: {owners}") |
191 | 192 | return True |
192 | 193 |
|
@@ -221,6 +222,18 @@ def create_removal_pr(repo: str, component: dict, repo_path: Path, dry_run: bool |
221 | 222 | print(f"Component directory not found: {component_dir}", file=sys.stderr) |
222 | 223 | return False |
223 | 224 |
|
| 225 | + # Regenerate category README to remove the component from the index |
| 226 | + category_dir = component_dir.parent |
| 227 | + is_component = "components" in path |
| 228 | + try: |
| 229 | + index_generator = CategoryIndexGenerator(category_dir, is_component=is_component) |
| 230 | + category_readme_content = index_generator.generate() |
| 231 | + category_readme_path = category_dir / "README.md" |
| 232 | + category_readme_path.write_text(category_readme_content) |
| 233 | + subprocess.run(["git", "add", str(category_readme_path)], check=True, capture_output=True) |
| 234 | + except Exception as e: |
| 235 | + print(f"Warning: Could not regenerate category README: {e}", file=sys.stderr) |
| 236 | + |
224 | 237 | # Commit the change |
225 | 238 | commit_msg = f"Remove stale component: {name}\n\nComponent has not been verified in {component['age_days']} days." |
226 | 239 | subprocess.run(["git", "commit", "-m", commit_msg], check=True, capture_output=True) |
@@ -258,8 +271,7 @@ def create_removal_pr(repo: str, component: dict, repo_path: Path, dry_run: bool |
258 | 271 |
|
259 | 272 |
|
260 | 273 | def handle_stale_components(repo: str, token: str | None, dry_run: bool) -> None: |
261 | | - """Handle stale components: issues for warnable or stale components, |
262 | | - and additionally creates PRs for fully stale components.""" |
| 274 | + """Handle stale components: issues for warnings, removal PRs for stale.""" |
263 | 275 | repo_path = REPO_ROOT |
264 | 276 | results = scan_repo(repo_path) |
265 | 277 | # Include both warning (270-360 days) and stale (>360 days) components |
|
0 commit comments