Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions dev/airflow-github
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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",
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Loading