From bc3fb7895866342c9d368074da411d33a2ae47a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Thu, 25 Sep 2025 10:16:18 +0200 Subject: [PATCH] ci: lib: integrate add_upstream_git_remote into get_base_commit add_upstream_git_remote was just being run at beginning of every method using get_changed_packages or get_changed_files, to have upstream available to use get_base_commit. So then, just move it to get_base_commit. As a positive side-effect, since the previous commit get_base_commit will just use the gitlab variable if available. So in CI we will just completely avoid running these two commands! Part-of: --- .ci/lib/apkbuild_linting.py | 1 - .ci/lib/build_changed_aports.py | 1 - .ci/lib/check_changed_aports_versions.py | 1 - .ci/lib/check_changed_kernels.py | 2 -- .ci/lib/common.py | 12 +++++------- .ci/lib/deviceinfo_linting.py | 1 - .ci/lib/generate_build_jobs.py | 1 - .ci/lib/verify_checksums.py | 1 - 8 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.ci/lib/apkbuild_linting.py b/.ci/lib/apkbuild_linting.py index cfe0425ef..5f77d5dbe 100755 --- a/.ci/lib/apkbuild_linting.py +++ b/.ci/lib/apkbuild_linting.py @@ -41,7 +41,6 @@ if __name__ == "__main__": custom_valid_options += kconfigcheck_categories os.environ["CUSTOM_VALID_OPTIONS"] = " ".join(custom_valid_options) - common.add_upstream_git_remote() apkbuilds = {file for file in common.get_changed_files(removed=False) if os.path.basename(file) == "APKBUILD"} if len(apkbuilds) < 1: diff --git a/.ci/lib/build_changed_aports.py b/.ci/lib/build_changed_aports.py index c88195c51..6f54444b2 100755 --- a/.ci/lib/build_changed_aports.py +++ b/.ci/lib/build_changed_aports.py @@ -32,7 +32,6 @@ if __name__ == "__main__": arch = sys.argv[1] # Get and print modified packages - common.add_upstream_git_remote() packages = common.get_changed_packages() # Load context diff --git a/.ci/lib/check_changed_aports_versions.py b/.ci/lib/check_changed_aports_versions.py index 41788ac3e..b0eb3793c 100755 --- a/.ci/lib/check_changed_aports_versions.py +++ b/.ci/lib/check_changed_aports_versions.py @@ -216,7 +216,6 @@ Thank you and sorry for the inconvenience. if __name__ == "__main__": # Get and print modified packages - common.add_upstream_git_remote() packages = common.get_changed_packages() if len(packages) == 0: print("no aports changed in this branch") diff --git a/.ci/lib/check_changed_kernels.py b/.ci/lib/check_changed_kernels.py index 27cdd93b1..88a46cc08 100755 --- a/.ci/lib/check_changed_kernels.py +++ b/.ci/lib/check_changed_kernels.py @@ -75,8 +75,6 @@ def show_error_all(): if __name__ == "__main__": - common.add_upstream_git_remote() - if "kconfigcheck.toml" in common.get_changed_files(): print("kconfigcheck.toml changed -> checking all kernels") if not check_kconfig_all(): diff --git a/.ci/lib/common.py b/.ci/lib/common.py index 0f008de5c..83a4fa304 100755 --- a/.ci/lib/common.py +++ b/.ci/lib/common.py @@ -32,13 +32,6 @@ def run_git(parameters, check=True, stderr=None): return None -def add_upstream_git_remote(): - """ Add a remote pointing to postmarketOS/pmaports. """ - run_git(["remote", "add", "upstream", - "https://gitlab.postmarketos.org/postmarketOS/pmaports.git"], False) - run_git(["fetch", "-q", "upstream"]) - - def commit_message_has_string(needle): base_commit = get_base_commit() @@ -102,6 +95,11 @@ def get_base_commit() -> str: if commit is not None: return commit + # Add a remote pointing to postmarketOS/pmaports + run_git(["remote", "add", "upstream", + "https://gitlab.postmarketos.org/postmarketOS/pmaports.git"], False) + run_git(["fetch", "-q", "upstream"]) + branch_upstream = f"upstream/{get_upstream_branch()}" commit_head = run_git(["rev-parse", "HEAD"])[:-1] commit_upstream = run_git(["rev-parse", branch_upstream])[:-1] diff --git a/.ci/lib/deviceinfo_linting.py b/.ci/lib/deviceinfo_linting.py index af78acccd..4c579e88b 100755 --- a/.ci/lib/deviceinfo_linting.py +++ b/.ci/lib/deviceinfo_linting.py @@ -8,7 +8,6 @@ import subprocess import sys if __name__ == "__main__": - common.add_upstream_git_remote() deviceinfo_files = {file for file in common.get_changed_files(removed=False) if os.path.basename(file) == "deviceinfo"} diff --git a/.ci/lib/generate_build_jobs.py b/.ci/lib/generate_build_jobs.py index f5af6c0d7..e609e7f53 100755 --- a/.ci/lib/generate_build_jobs.py +++ b/.ci/lib/generate_build_jobs.py @@ -184,7 +184,6 @@ if __name__ == "__main__": devices_under_test = set() packages_modified = set() # Get and print modified packages - common.add_upstream_git_remote() for file in common.get_changed_files(): path = Path(file) diff --git a/.ci/lib/verify_checksums.py b/.ci/lib/verify_checksums.py index 72ae12b49..26c5c6b74 100755 --- a/.ci/lib/verify_checksums.py +++ b/.ci/lib/verify_checksums.py @@ -26,7 +26,6 @@ def verify_checksums(packages): if __name__ == "__main__": # Get and print modified packages - common.add_upstream_git_remote() packages = common.get_changed_packages() # Load context