Skip to content

Commit

Permalink
Fix getting correct commit from multiple referenced PR (#33411)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ephraimbuddy authored Aug 15, 2023
1 parent a1576d3 commit 5b104a9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dev/airflow-github
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 5b104a9

Please sign in to comment.