Skip to content
Extraits de code Groupes Projets
Valider 412e6b4a rédigé par Théo - Le Filament's avatar Théo - Le Filament
Parcourir les fichiers

build(get_addons): remove module directory when already exists, improve git...

build(get_addons): remove module directory when already exists, improve git repo cloning and use environment variable for path to the cloned repository
parent 58344464
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -5,6 +5,7 @@ set -e
ODOO_ROOT_DIR=${ODOO_ROOT_DIR:-'/opt/odoo'}
SAVE_COMMITS_DIR=${SAVE_COMMITS_DIR:-'/opt/odoo_commits'}
SAVE_COMMITS_FILENAME=${SAVE_COMMITS_FILENAME:-'custom_addons'}
TMP_REPO_PATH=${TEMP_REPO_PATH:-'/tmp/repo'}
save_commit() {
repo="$1"
......@@ -22,18 +23,36 @@ dst="$1"
shift
modules="$@"
git clone --filter=tree:0 "${repo}" /tmp/repo
git -C /tmp/repo checkout "${ref}"
commit="$(git -C /tmp/repo rev-parse HEAD)"
set +e
git clone --branch "${ref}" --filter=tree:0 "${repo}" "${TMP_REPO_PATH}"
if [ "$?" -ne 0 ]; then
git clone --filter=tree:0 "${repo}" "${TMP_REPO_PATH}"
if [ "$?" -ne 0 ]; then
git clone --single-branch --branch "${ref}" --depth 1 "${repo}" "${TMP_REPO_PATH}"
if [ "$?" -ne 0 ]; then
git clone "${repo}" "${TMP_REPO_PATH}"
fi
fi
fi
set -e
git -C "${TMP_REPO_PATH}" checkout "${ref}"
commit="$(git -C ${TMP_REPO_PATH} rev-parse HEAD)"
if [ -n "$modules" ]; then
for module in $modules; do
mv "/tmp/repo/${module}" "${ODOO_ROOT_DIR}/${dst}/"
if [ -d "${ODOO_ROOT_DIR}/${dst}/${module}" ]; then
rm -r "${ODOO_ROOT_DIR}/${dst}/${module}"
fi
mv "${TMP_REPO_PATH}/${module}" "${ODOO_ROOT_DIR}/${dst}/"
save_commit "$repo" "$commit" "$module" "$dst"
done
else
module="$(basename $dst)"
if [ -d "${ODOO_ROOT_DIR}/${dst}" ]; then
rm -r "${ODOO_ROOT_DIR}/${dst}"
fi
mkdir -p "/${ODOO_ROOT_DIR}/${dst}"
mv /tmp/repo/* "${ODOO_ROOT_DIR}/${dst}/"
mv ${TMP_REPO_PATH}/* "${ODOO_ROOT_DIR}/${dst}/"
save_commit "$repo" "$commit" "$module" "$dst"
fi
rm -r /tmp/repo
rm -r "${TMP_REPO_PATH}"
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter