ci: common: don't run git if we can just get the base sha from gitlab

Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7078>
This commit is contained in:
Pablo Correa Gómez 2025-09-25 10:11:09 +02:00 committed by The Friendly Merge Bot
parent 1d6eea7261
commit 7bf7616490
No known key found for this signature in database

View file

@ -98,6 +98,10 @@ def get_base_commit() -> str:
"""Get the base commit that can be compared with HEAD to get all commits in the
given branch/merge request."""
commit = os.getenv("CI_MERGE_REQUEST_DIFF_BASE_SHA")
if commit is not None:
return commit
branch_upstream = f"upstream/{get_upstream_branch()}"
commit_head = run_git(["rev-parse", "HEAD"])[:-1]
commit_upstream = run_git(["rev-parse", branch_upstream])[:-1]