Skip to content
Snippets Groups Projects
Commit 8d052e31 authored by Théo - Le Filament's avatar Théo - Le Filament
Browse files

build(get_addons): remove module directory when already exists and use...

build(get_addons): remove module directory when already exists and use environment variable for path to the cloned repository
parent a3dd2d07
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ set -e ...@@ -5,7 +5,7 @@ set -e
ODOO_ROOT_DIR=${ODOO_ROOT_DIR:-'/opt/odoo'} ODOO_ROOT_DIR=${ODOO_ROOT_DIR:-'/opt/odoo'}
SAVE_COMMITS_DIR=${SAVE_COMMITS_DIR:-'/opt/odoo_commits'} SAVE_COMMITS_DIR=${SAVE_COMMITS_DIR:-'/opt/odoo_commits'}
SAVE_COMMITS_FILENAME=${SAVE_COMMITS_FILENAME:-'custom_addons'} SAVE_COMMITS_FILENAME=${SAVE_COMMITS_FILENAME:-'custom_addons'}
TMP_REPO_PATH='/tmp/repo' TMP_REPO_PATH=${TEMP_REPO_PATH:-'/tmp/repo'}
save_commit() { save_commit() {
repo="$1" repo="$1"
...@@ -25,20 +25,26 @@ modules="$@" ...@@ -25,20 +25,26 @@ modules="$@"
set +e set +e
git clone --single-branch --branch "${ref}" --depth 1 "${repo}" "${TMP_REPO_PATH}" git clone --single-branch --branch "${ref}" --depth 1 "${repo}" "${TMP_REPO_PATH}"
if [ "$?" != 0 ]; then if [ "$?" -ne 0 ]; then
git clone "${repo}" "${TMP_REPO_PATH}" git clone "${repo}" "${TMP_REPO_PATH}"
fi fi
set -e set -e
git -C "${TMP_REPO_PATH}" checkout "${ref}" git -C "${TMP_REPO_PATH}" checkout "${ref}"
commit="$(git -C /tmp/repo rev-parse HEAD)" commit="$(git -C ${TMP_REPO_PATH} rev-parse HEAD)"
if [ -n "$modules" ]; then if [ -n "$modules" ]; then
for module in $modules; do for module in $modules; do
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}/" mv "${TMP_REPO_PATH}/${module}" "${ODOO_ROOT_DIR}/${dst}/"
save_commit "$repo" "$commit" "$module" "$dst" save_commit "$repo" "$commit" "$module" "$dst"
done done
else else
module="$(basename $dst)" module="$(basename $dst)"
if [ -d "${ODOO_ROOT_DIR}/${dst}" ]; then
rm -r "${ODOO_ROOT_DIR}/${dst}"
fi
mkdir -p "/${ODOO_ROOT_DIR}/${dst}" mkdir -p "/${ODOO_ROOT_DIR}/${dst}"
mv ${TMP_REPO_PATH}/* "${ODOO_ROOT_DIR}/${dst}/" mv ${TMP_REPO_PATH}/* "${ODOO_ROOT_DIR}/${dst}/"
save_commit "$repo" "$commit" "$module" "$dst" save_commit "$repo" "$commit" "$module" "$dst"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment