From a37ef6f7bedb51a079110b5d254523f4affd0bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20-=20Le=20Filament?= <theo@le-filament.com> Date: Wed, 22 May 2024 16:27:22 +0200 Subject: [PATCH] fix(fetch_repos): raise an error if the git command fails --- templates/fetch_repos | 16 +++++++++++++--- templates/fetch_repos_addons | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/templates/fetch_repos b/templates/fetch_repos index 0688040..79f3740 100755 --- a/templates/fetch_repos +++ b/templates/fetch_repos @@ -4,11 +4,12 @@ #!/usr/bin/env python3 {% endif %} # -*- coding: utf-8 -*- + import grp import os import pwd import shutil -from subprocess import call +import subprocess import yaml DEFAULT_PRIVATE_REPO = "/opt/odoo/private_addons" @@ -20,8 +21,17 @@ if os.path.isfile(REPO_FILE): repos = yaml.safe_load(open(REPO_FILE)) if repos: for repo in repos: - call(["git", "clone", "-b", repos[repo]["branch"], "--depth", "1", repos[repo]["url"], - DEFAULT_PRIVATE_REPO+"/"+repo]) + subprocess.run( + [ + "git", + "clone", + "--single-branch", + "--branch", repos[repo]["branch"], + "--depth", "1", + repos[repo]["url"], + DEFAULT_PRIVATE_REPO + "/" + repo + ], + check=True) {% if instance_odoo_setup.odoo_version == '10.0' %} if os.path.isdir("/opt/odoo/private_addons/lf_theme"): diff --git a/templates/fetch_repos_addons b/templates/fetch_repos_addons index 249bd87..8b3eee5 100755 --- a/templates/fetch_repos_addons +++ b/templates/fetch_repos_addons @@ -4,11 +4,12 @@ #!/usr/bin/env python3 {% endif %} # -*- coding: utf-8 -*- + import grp import os import pwd import shutil -from subprocess import call +import subprocess {% if instance_odoo_setup.odoo_version == '10.0' %} from urlparse import urlsplit {% else %} @@ -26,8 +27,16 @@ if os.path.isfile(REPO_ADDON_FILE): if repos: for url in repos: repo = urlsplit(url).path - call(["git", "clone", "-b", repos[url]["branch"], "--depth", "1", - url, "/tmp/addon"+repo]) + subprocess.run( + [ + "git", + "clone", + "--single-branch", + "--branch", repos[url]["branch"], + "--depth", "1", + url, "/tmp/addon" + repo + ], + check=True) for module in repos[url]["modules"]: shutil.move("/tmp/addon"+repo+"/"+module, DEFAULT_PRIVATE_REPO+"/"+module) -- GitLab