Get slugs for fulltext files changed in this PR (git diff vs base).
()
| 33 | |
| 34 | |
| 35 | def _get_changed_slugs() -> set[str] | None: |
| 36 | """Get slugs for fulltext files changed in this PR (git diff vs base).""" |
| 37 | base_ref = os.environ.get("GITHUB_BASE_REF", "") |
| 38 | if not base_ref: |
| 39 | return None |
| 40 | |
| 41 | try: |
| 42 | result = subprocess.run( |
| 43 | ["git", "diff", "--name-only", f"origin/{base_ref}...HEAD"], |
| 44 | capture_output=True, text=True, cwd=str(ROOT), |
| 45 | ) |
| 46 | if result.returncode != 0: |
| 47 | return None |
| 48 | |
| 49 | slugs = set() |
| 50 | for line in result.stdout.strip().split('\n'): |
| 51 | line = line.strip() |
| 52 | if line.startswith("nmpa/guidance/fulltext/") and line.endswith(".md"): |
| 53 | fname = line.split("/")[-1] |
| 54 | if not fname.endswith(".en.md"): |
| 55 | slugs.add(fname[:-3]) |
| 56 | return slugs |
| 57 | except Exception: |
| 58 | return None |
| 59 | |
| 60 | |
| 61 | def main(): |