Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions exemples/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions odooghost/config/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class AddonsConfig(BaseModel):
"""
Addons path local path
"""
shallow: bool = True
"""
Shallow clone for remote addons
"""

@property
def name(self) -> str:
Expand Down
25 changes: 17 additions & 8 deletions odooghost/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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} ...")
Expand Down
2 changes: 2 additions & 0 deletions odooghost/services/odoo/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
Loading