This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-0-test by this push:
     new e3637a216b5 [v3-0-test] Fix cherry-pick detection in airflow-github 
script (#54287) (#54289)
e3637a216b5 is described below

commit e3637a216b55bc4d1ab0b4941cc1d553b6eea944
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Aug 8 22:14:38 2025 +0100

    [v3-0-test] Fix cherry-pick detection in airflow-github script (#54287) 
(#54289)
    
    - Fix `is_cherrypicked` function to detect PRs with multiple reference 
numbers
    - Differentiate between Closed and Merged status for better PR state 
visibility
    - Add PEP 723 script dependencies for easier execution with 'uv run 
--no-project'
    
    The cherry-pick detection was failing for PRs that had additional PR numbers
    appended during cherry-picking (e.g., '(#53955) (#53964)'). This change 
improves
    release management workflow by providing clearer PR status information.
    (cherry picked from commit 29a1cb0cfde9d99b1774571688ed86cb60123896)
    
    Co-authored-by: Kaxil Naik <[email protected]>
---
 dev/airflow-github | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/dev/airflow-github b/dev/airflow-github
index 5866f13f4ff..d13d28383f8 100755
--- a/dev/airflow-github
+++ b/dev/airflow-github
@@ -1,4 +1,14 @@
 #!/usr/bin/env python3
+# /// script
+# requires-python = ">=3.10"
+# dependencies = [
+#     "GitPython",
+#     "PyGithub",
+#     "rich-click",
+#     "packaging",
+#     "rich",
+# ]
+# ///
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -43,7 +53,8 @@ GIT_LOG_FORMAT = "%x1f".join(["%h", "%an", "%ae", "%ad", 
"%s", "%b"]) + "%x1e"
 pr_title_re = re.compile(r".*\((#[0-9]{1,6})\)$")
 
 STATUS_COLOR_MAP = {
-    "Closed": "green",
+    "Closed": "yellow",
+    "Merged": "green",
     "Open": "red",
 }
 
@@ -102,14 +113,14 @@ def get_commit_in_main_associated_with_pr(repo: git.Repo, 
issue: Issue) -> str |
 
 def is_cherrypicked(repo: git.Repo, issue: Issue, previous_version: str | None 
= None) -> bool:
     """Check if a given issue is cherry-picked in the current branch or not"""
-    log_args = ["--format=%H %s", f"--grep=(#{issue.number})$"]
+    log_args = ["--format=%H %s", f"--grep=(#{issue.number})"]
     if previous_version:
         log_args.append(previous_version + "..")
     log_output = repo.git.log(*log_args)
 
     for commit_line in log_output.splitlines():
-        # We only want the commit for the PR where squash-merge added (#PR) at 
the end of subject
-        if commit_line and commit_line.endswith(f"(#{issue.number})"):
+        # Check if the PR number exists in the commit message (handles 
cherry-picked commits with multiple PR numbers)
+        if commit_line and f"(#{issue.number})" in commit_line:
             return True
     return False
 
@@ -270,9 +281,15 @@ def compare(target_version, github_token, 
previous_version=None, show_uncherrypi
     )
     for issue in milestone_issues:
         commit_in_main = get_commit_in_main_associated_with_pr(repo, issue)
-        status = issue.state.capitalize()
         issue_is_pr = is_pr(issue)
 
+        # Determine status - differentiate between Closed and Merged for PRs
+        if issue_is_pr and issue.state == "closed":
+            pr = issue.as_pull_request()
+            status = "Merged" if pr.is_merged() else "Closed"
+        else:
+            status = issue.state.capitalize()
+
         # Checks if commit was cherrypicked into branch.
         if is_cherrypicked(repo, issue, previous_version):
             num_cherrypicked += 1

Reply via email to