meel-ayush commented on code in PR #76955:
URL: https://github.com/apache/airflow/pull/76955#discussion_r4578278284


##########
dev/breeze/src/airflow_breeze/utils/fork_compare.py:
##########
@@ -68,18 +179,39 @@ def get_fork_changes(*, fork_owner: str, sha: str, base: 
str) -> ForkChanges:
         capture_output=True,
         text=True,
     )
-    if result.returncode != 0:
+    compare_merge_base = None
+    if result.returncode == 0:
+        compare = json.loads(result.stdout or "{}")
+        entries = compare.get("files", [])
+        files = tuple(path for entry in entries for path in entry)
+        compare_merge_base = compare.get("merge_base")
+        if len(entries) < COMPARE_FILE_CAP:
+            return ForkChanges(files=files, truncated=False, 
merge_base=compare_merge_base)
+        console_print(
+            f"[warning]Compare API returned {len(entries)} files (capped at 
{COMPARE_FILE_CAP}), "
+            "falling back to local git diff to avoid truncation[/]"
+        )
+    else:
+        files = ()
         console_print(
             f"[warning]Could not compare {fork_owner}:{sha} with 
{APACHE_AIRFLOW_GITHUB_REPOSITORY}:{base}, "
-            f"so everything runs: {result.stderr.strip()}[/]"
+            f"trying local git diff: {result.stderr.strip()}[/]"
         )
-        return ForkChanges(files=(), truncated=True)
-    compare = json.loads(result.stdout or "{}")
-    entries = compare.get("files", [])
-    files = tuple(path for entry in entries for path in entry)
-    return ForkChanges(
-        files=files, truncated=len(entries) >= COMPARE_FILE_CAP, 
merge_base=compare.get("merge_base")
+
+    local_changes = _get_local_git_changes(
+        base=base,
+        sha=sha,
+        known_merge_base=compare_merge_base if result.returncode == 0 else 
None,
     )
+    if local_changes is not None:
+        console_print(
+            f"[info]Local git diff resolved {len(local_changes.files)} changed 
files "
+            f"(merge base: {local_changes.merge_base})[/]"
+        )
+        return local_changes

Review Comment:
   Fixed via git show.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to