From 70a78df45ed0aa9d01e8c6b447b40061e6621a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 17 Dec 2024 12:19:12 +0100 Subject: [PATCH 1/3] fix: remove unused params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Han --- depends_on_stage2 | 2 -- 1 file changed, 2 deletions(-) diff --git a/depends_on_stage2 b/depends_on_stage2 index 399c7e8..ea9d017 100755 --- a/depends_on_stage2 +++ b/depends_on_stage2 @@ -65,8 +65,6 @@ def extract_change(change_info, main_url, work_dir): ) else: return extract_github_change( - fork_url, - change_info["branch"], main_url, pr_number, work_dir, From c476ecfdeb93a7cf078c965d0f105d5700bce4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 17 Dec 2024 12:19:38 +0100 Subject: [PATCH 2/3] feat: print stderr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Whene executing a command let's print stderr on errors as well as the exit code. Signed-off-by: Sébastien Han --- depends_on/common.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/depends_on/common.py b/depends_on/common.py index 2bbfc40..d40b027 100644 --- a/depends_on/common.py +++ b/depends_on/common.py @@ -3,6 +3,7 @@ import json import os import re +import subprocess import sys import urllib.parse from urllib.request import Request, urlopen @@ -347,8 +348,14 @@ def check_error(status, message): def command(cmd): "Execute a command" log(f"+ {cmd}") - ret = os.system(cmd) - check_error(ret == 0, f"Command failed with exit code {ret}") + try: + _ = subprocess.run( + cmd, shell=True, stderr=subprocess.PIPE, text=True, check=True + ) + except subprocess.CalledProcessError as e: + log(f"Command failed with exit code {e.returncode}") + log(e.stderr) + sys.exit(1) def is_gerrit(change_url): From b20a0950db69022bf40f12627e51e5fab6529efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 17 Dec 2024 12:20:26 +0100 Subject: [PATCH 3/3] fix: unshallow and merge main into extra dirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When extra-dirs is used we also need to apply main branch into each directory. Signed-off-by: Sébastien Han --- depends_on_stage2 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/depends_on_stage2 b/depends_on_stage2 index ea9d017..4b64c61 100755 --- a/depends_on_stage2 +++ b/depends_on_stage2 @@ -71,6 +71,11 @@ def extract_change(change_info, main_url, work_dir): ) +def extract_default_branch(work_dir) -> str: + "Return the default branch of the git repository in work_dir." + return os.popen(f"cd {work_dir} && git rev-parse --abbrev-ref HEAD").read().strip() + + def main(check_mode): "Main function." @@ -152,6 +157,10 @@ def main(check_mode): # lookup if the remote of the directory is part of the depends_on # if yes, then we need to extract the right branch origin_url = extract_origin_url(real_extra_dir) + if not check_mode: + main_branch = extract_default_branch(real_extra_dir) + unshallow(real_extra_dir, main_branch) + merge_main_branch(real_extra_dir, main_branch) for depends_on_url in depends_on + [data["change_url"]]: log(f"depends_on_url: {depends_on_url} {origin_url}") if depends_on_url.startswith(origin_url):