Merge pull request #69538 from ClickHouse/fix-latest-sync-commit

Get rid of broken `get_commits().reversed`
This commit is contained in:
Mikhail f. Shiryaev 2024-09-12 05:34:35 +00:00 committed by GitHub
commit 8a70017815
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,6 +9,7 @@ from urllib.parse import quote
from unidiff import PatchSet # type: ignore
from build_download_helper import get_gh_api
from ci_config import Labels
from env_helper import (
GITHUB_EVENT_PATH,
GITHUB_REPOSITORY,
@ -16,7 +17,6 @@ from env_helper import (
GITHUB_SERVER_URL,
GITHUB_UPSTREAM_REPOSITORY,
)
from ci_config import Labels
from get_robot_token import get_best_robot_token
from github_helper import GitHub
@ -459,16 +459,18 @@ class PRInfo:
sync_repo = gh.get_repo(GITHUB_REPOSITORY)
sync_pr = sync_repo.get_pull(self.number)
# Find the commit that is in both repos, upstream and cloud
sync_commits = sync_pr.get_commits().reversed
upstream_commits = upstream_pr.get_commits().reversed
# Do not ever use `reversed` here, otherwise the list of commits is not full
sync_commits = list(sync_pr.get_commits())
upstream_commits = list(upstream_pr.get_commits())
# Github objects are compared by _url attribute. We can't compare them directly and
# should compare commits by SHA1
upstream_shas = [c.sha for c in upstream_commits]
logging.info("Commits in upstream PR:\n %s", ", ".join(upstream_shas))
sync_shas = [c.sha for c in sync_commits]
logging.info("Commits in sync PR:\n %s", ", ".join(reversed(sync_shas)))
logging.info("Commits in sync PR:\n %s", ", ".join(sync_shas))
# find latest synced commit
# find latest synced commit, search from the latest
upstream_commits.reverse()
last_synced_upstream_commit = None
for commit in upstream_commits:
if commit.sha in sync_shas: