diff --git a/scripts/apply_reviewer_rejections.py b/scripts/apply_reviewer_rejections.py index 29c36e5..552340d 100644 --- a/scripts/apply_reviewer_rejections.py +++ b/scripts/apply_reviewer_rejections.py @@ -205,7 +205,14 @@ def main() -> int: pr = prs[0] pr_id = int(pr.get("pullRequestId")) - _run_git(args.repo_root, ["fetch", "--quiet", "origin", baseline_branch, drift_branch]) + _run_git(args.repo_root, ["fetch", "--quiet", "origin", baseline_branch]) + try: + _run_git(args.repo_root, ["fetch", "--quiet", "origin", drift_branch]) + except RuntimeError as exc: + if "couldn't find remote ref" in str(exc).lower() or "could not find remote ref" in str(exc).lower(): + print(f"Drift branch '{drift_branch}' not found on origin; nothing to reject.") + return 0 + raise diff_paths = _run_diff_name_only(args.repo_root, baseline_branch, drift_branch) changed_paths = { p.strip() diff --git a/scripts/ensure_rolling_pr.py b/scripts/ensure_rolling_pr.py index 4d735d7..0d51d5e 100644 --- a/scripts/ensure_rolling_pr.py +++ b/scripts/ensure_rolling_pr.py @@ -512,7 +512,14 @@ def main() -> int: print("##vso[task.setvariable variable=DRIFT_PR_SUPPRESSED;isOutput=true]0") return 0 - _run_git(args.repo_root, ["fetch", "--quiet", "origin", baseline_branch, drift_branch]) + _run_git(args.repo_root, ["fetch", "--quiet", "origin", baseline_branch]) + try: + _run_git(args.repo_root, ["fetch", "--quiet", "origin", drift_branch]) + except RuntimeError as exc: + if "couldn't find remote ref" in str(exc).lower() or "could not find remote ref" in str(exc).lower(): + pass # Drift branch may not exist yet; fallback to HEAD below. + else: + raise baseline_commitish = f"origin/{baseline_branch}" if _ref_has_commit(args.repo_root, f"origin/{baseline_branch}") else baseline_branch drift_commitish = f"origin/{drift_branch}" if _ref_has_commit(args.repo_root, f"origin/{drift_branch}") else "HEAD" if not _workload_config_diff_exists( diff --git a/scripts/update_pr_review_summary.py b/scripts/update_pr_review_summary.py index 9a1c0aa..34ee0f8 100644 --- a/scripts/update_pr_review_summary.py +++ b/scripts/update_pr_review_summary.py @@ -2498,7 +2498,14 @@ def main() -> int: return 0 _debug(f"Active rolling PR detected: pr_id={pr_id}, source={source_ref}, target={target_ref}") - _run_git(args.repo_root, ["fetch", "--quiet", "origin", baseline_branch, drift_branch]) + _run_git(args.repo_root, ["fetch", "--quiet", "origin", baseline_branch]) + try: + _run_git(args.repo_root, ["fetch", "--quiet", "origin", drift_branch]) + except RuntimeError as exc: + if "couldn't find remote ref" in str(exc).lower() or "could not find remote ref" in str(exc).lower(): + print(f"Drift branch '{drift_branch}' not found on origin; skipping summary update.") + return 0 + raise diff_output = _run_diff_name_status(args.repo_root, baseline_branch, drift_branch) changes = _parse_changes(diff_output, args.backup_folder, args.reports_subdir) _debug(f"Parsed non-doc/report changes for summary: count={len(changes)}")