From b97994aa22938419866f3a4880147608cb37a2ac Mon Sep 17 00:00:00 2001 From: Ephraim Anierobi Date: Tue, 15 Aug 2023 16:31:55 +0100 Subject: [PATCH] Fix getting correct commit from multiple referenced PR When a PR is referenced by other PRs, our dev tool for getting the correct commit lists the latest commit when looking for the commmit sha but we should get the oldest. --- dev/airflow-github | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/airflow-github b/dev/airflow-github index 115ed48d19169..69ca8ec53cc0e 100755 --- a/dev/airflow-github +++ b/dev/airflow-github @@ -83,9 +83,10 @@ def get_issue_type(issue): def get_commit_in_main_associated_with_pr(repo: git.Repo, issue: Issue) -> str | None: """For a PR, find the associated merged commit & return its SHA""" if issue.pull_request: - commit = repo.git.log(f"--grep=#{issue.number}", "origin/main", "--format=%H") + commit = repo.git.log("--reverse", f"--grep=#{issue.number}", "origin/main", "--format=%H") if commit: - return commit + # We only want the oldest commit that referenced this PR number + return commit.splitlines()[0] else: pr: PullRequest = issue.as_pull_request() if pr.is_merged():