Skip to content

Commit

Permalink
[FIX] now we are removing the git folder before trying to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
az-adhoc authored and jjscarafia committed Sep 12, 2024
1 parent 965f50b commit 89c96b9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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= \
Expand All @@ -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
```
26 changes: 21 additions & 5 deletions entrypoint.d/000-aggregate-custom-repos
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

0 comments on commit 89c96b9

Please sign in to comment.