From 89c96b99fc235a0da69b30cd1477585355ac96eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAndres?= Date: Thu, 12 Sep 2024 09:59:19 -0300 Subject: [PATCH] [FIX] now we are removing the git folder before trying to merge --- Dockerfile | 10 +++++----- README.MD | 9 +++++++-- entrypoint.d/000-aggregate-custom-repos | 26 ++++++++++++++++++++----- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21dd256..172621a 100755 --- a/Dockerfile +++ b/Dockerfile @@ -51,14 +51,14 @@ RUN $RESOURCES/saas-build USER odoo # Aggregate new repositories of this image -RUN autoaggregate --config "$RESOURCES/saas-odoo_project_repos.yml" --output $SOURCES/repositories \ - && autoaggregate --config "$RESOURCES/saas-odoo_project_version_repos.yml" --output $SOURCES/repositories \ +RUN git config --global init.defaultBranch main \ + && autoaggregate --config "$RESOURCES/saas-odoo_project_repos.yml" --output "$SOURCES/repositories" \ + && autoaggregate --config "$RESOURCES/saas-odoo_project_version_repos.yml" --output "$SOURCES/repositories" \ + # Report to provider all repos HEADs + && find $SOURCES -name "*.git" -type d -execdir sh -c "pwd && echo , && git log -n 1 --remotes=origin --pretty=format:\"%H\" && echo \;; " \; | xargs -n3 > /tmp/repo_heads.txt ; curl -X POST $BASE_URL/report_sha$URL_SUFIX\&minor_version=`date -u +%Y.%m.%d` -H "Content-Type: application/json" -H "Accept: application/json" -d "@/tmp/repo_heads.txt" \ # Delete unused git from repositories && find $SOURCES -type d -name ".git" -exec rm -rf {} + -# Report to provider all repos HEADs -RUN find $SOURCES -name "*.git" -type d -execdir sh -c "pwd && echo , && git log -n 1 --remotes=origin --pretty=format:\"%H\" && echo \;; " \; | xargs -n3 > /tmp/repo_heads.txt ; curl -X POST $BASE_URL/report_sha$URL_SUFIX\&minor_version=`date -u +%Y.%m.%d` -H "Content-Type: application/json" -H "Accept: application/json" -d "@/tmp/repo_heads.txt" - # Install odoo RUN pip install --user --no-cache-dir -e $SOURCES/odoo diff --git a/README.MD b/README.MD index 0d095e4..86832ba 100644 --- a/README.MD +++ b/README.MD @@ -9,8 +9,7 @@ BASE_IMAGE_TAG=17.0 ```sh export DOCKER_BUILDKIT=1 \ && docker build --no-cache \ - -t adhoc/odoo-adhoc:17.3-dev \ - --build-arg BASE_IMAGE_REPO=adhoc/odoo \ + -t adhoc/odoo-adhoc:17.0-dev \ --build-arg BASE_IMAGE_TAG=17.0-dev \ --build-arg GITHUB_BOT_TOKEN= \ --build-arg SAAS_PROVIDER_TOKEN= \ @@ -19,3 +18,9 @@ export DOCKER_BUILDKIT=1 \ -f Dockerfile . # docker push adhoc/odoo-adhoc:17.0-dev ``` + +Run the image + +```sh +docker run -it --rm --entrypoint="" adhoc/odoo-adhoc:17.0-dev bash +``` diff --git a/entrypoint.d/000-aggregate-custom-repos b/entrypoint.d/000-aggregate-custom-repos index 312363e..70cd648 100755 --- a/entrypoint.d/000-aggregate-custom-repos +++ b/entrypoint.d/000-aggregate-custom-repos @@ -1,9 +1,13 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from multiprocessing import cpu_count import os +import shutil from subprocess import check_call import logging + +import yaml _logger = logging.getLogger(__name__) # Recreate and run git-aggregator @@ -18,13 +22,25 @@ if REPOS_YAML and SOURCES: file.write(content) _logger.info('Running git aggregator on custom-repos.yml..') + + output = os.path.join(SOURCES, 'repositories') + with open(repos_file) as yaml_file: + for doc in yaml.safe_load_all(yaml_file): + for repo in doc: + repo_path = os.path.abspath(os.path.join(output, repo)) + print(repo_path) + if os.path.exists(repo_path) and os.path.isdir(repo_path): + shutil.rmtree(repo_path) + try: check_call([ - 'autoaggregate', - '--config', - repos_file, - '--output', - os.path.join(SOURCES, 'repositories'), + "gitaggregate", + "--expand-env", + "--config", + os.path.abspath(repos_file), + "--jobs", + str(cpu_count() or 1), + "aggregate", ]) except Exception as e: _logger.error("IMPORTANT! Couldn't run gitaggregate correctly. This is what we get: %s" % e)