diff --git a/exemples/full.yml b/exemples/full.yml index b7aab45..5dd4c3b 100644 --- a/exemples/full.yml +++ b/exemples/full.yml @@ -4,16 +4,20 @@ services: version: 16.0 # or 15.0 14.0 ... cmdline: "--workers=2" # Odoo cmdline addons: - - - type: remote + - type: remote mode: mount # mount addons in container origin: https://github.com/OCA/project.git branch: "16.0" path: /home/remy/ons-docker/git/16.0/OCA/project # will be resolved from home - - - type: local + - type: local mode: copy # copy addons in image path: /home/remy/ons-docker/git/16.0/OCA/crm + - type: remote + mode: mount + origin: https://github.com/OCA/other.git + branch: "16.0" + shallow: false # full history (no shallow clone) + path: /path/to/other dependencies: apt: - pkg-config diff --git a/odooghost/config/addons.py b/odooghost/config/addons.py index 7db3ed0..b88ec09 100644 --- a/odooghost/config/addons.py +++ b/odooghost/config/addons.py @@ -36,6 +36,10 @@ class AddonsConfig(BaseModel): """ Addons path local path """ + shallow: bool = True + """ + Shallow clone for remote addons + """ @property def name(self) -> str: diff --git a/odooghost/git.py b/odooghost/git.py index f91e0c2..8415205 100644 --- a/odooghost/git.py +++ b/odooghost/git.py @@ -83,16 +83,25 @@ def update( class Git: @classmethod - def clone(cls, path: Path, url: str, branch: str, depth: int = 1) -> Repo: + def clone( + cls, + path: Path, + url: str, + branch: str, + depth: int = 1, + shallow: bool = True, + ) -> Repo: logger.debug(f"Cloning {url} to {path} branch {branch} ...") try: - repo = Repo.clone_from( - url=url, - to_path=path, - branch=branch, - progress=GitRemoteProgress(), - depth=depth, - ) + clone_kwargs = { + "url": url, + "to_path": path, + "branch": branch, + "progress": GitRemoteProgress(), + } + if shallow: + clone_kwargs["depth"] = depth + repo = Repo.clone_from(**clone_kwargs) if repo.submodules: for sm in repo.submodules: logger.debug(f"Cloning submodule {sm.repo} ...") diff --git a/odooghost/services/odoo/addons.py b/odooghost/services/odoo/addons.py index 0625ada..7f436ec 100644 --- a/odooghost/services/odoo/addons.py +++ b/odooghost/services/odoo/addons.py @@ -95,6 +95,7 @@ def ensure(self) -> None: path=path, url=addons.origin.url, branch=addons.branch or str(self.odoo_version), + shallow=addons.shallow, ) def pull(self, depth: int = 1) -> None: @@ -121,6 +122,7 @@ def pull(self, depth: int = 1) -> None: url=addons.origin.url, branch=addons.branch or str(self.odoo_version), depth=depth, + shallow=addons.shallow, ) @property