Просмотр исходного кода

For a dependent PR, include a link to changes to review. (#7124)

Instead of linking to the first commit to be reviewed, link to the
complete series of commits to review. Include a warning if not all the
commits in that range should be reviewed due to non-linear history.

Assisted-by: Gemini via Antigravity
Richard Smith 5 дней назад
Родитель
Сommit
aa8f9d8c00
1 измененных файлов с 18 добавлено и 5 удалено
  1. 18 5
      github_tools/check_dependent_pr.py

+ 18 - 5
github_tools/check_dependent_pr.py

@@ -359,6 +359,13 @@ def _process_pr(
                 first_independent_commit_oid = oid
                 break
 
+        any_later_dependent_oids = False
+        if first_independent_commit_oid:
+            idx = current_oids.index(first_independent_commit_oid)
+            any_later_dependent_oids = any(
+                oid in dependent_oids for oid in current_oids[idx + 1 :]
+            )
+
     if (
         open_deps == parsed_open_deps
         and merged_deps == parsed_merged_deps
@@ -382,14 +389,20 @@ def _process_pr(
     if open_deps:
         pr_list_str = ", ".join([f"#{num}" for num in open_deps])
         if first_independent_commit_oid:
-            short_hash = first_independent_commit_oid[:8]
-            first_commit_linked = (
-                f"[{short_hash}]({pr_number}/commits/{short_hash})"
+            changes_url = (
+                "https://github.com/carbon-language/carbon-lang/pull/"
+                f"{pr_number}/changes/{first_independent_commit_oid}..HEAD"
             )
             comment_body += (
-                f"Depends on {pr_list_str}, start review at "
-                f"{first_commit_linked}"
+                f"Depends on {pr_list_str}, start review with "
+                f"[these changes]({changes_url})"
             )
+            if any_later_dependent_oids:
+                comment_body += (
+                    "\n\n> [!WARNING]\n"
+                    "> Also contains changes from dependent PRs due to "
+                    "non-linear history."
+                )
         else:
             comment_body += (
                 f"Depends on {pr_list_str}, unable to identify starting review "