Skip to content
Open
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
2 changes: 1 addition & 1 deletion odev/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
# or merged change.
# ------------------------------------------------------------------------------

__version__ = "4.19.1"
__version__ = "4.19.2"

Check notice on line 25 in odev/_version.py

View workflow job for this annotation

GitHub Actions / version-bump

Patch Update
16 changes: 15 additions & 1 deletion odev/commands/database/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from odev.common import args
from odev.common.commands import DatabaseCommand
from odev.common.databases import LocalDatabase, Repository
from odev.common.logging import logging


logger = logging.getLogger(__name__)


class QuickStartCommand(DatabaseCommand):
Expand Down Expand Up @@ -37,6 +41,13 @@ class QuickStartCommand(DatabaseCommand):
aliases=["-F", "--filestore"],
description="Include the filestore when downloading a backup of the database.",
)
toggle_clone_repo = args.Flag(
aliases=["-C", "--toggle_clone_repo"],
description="""Toggle to clone the repository containing code customization for the selected database.
If not given, default to `quickstart should_clone_repo` configuration value (`True` if unset).
If given, negate the configuration value
""",
)

_database_allowed_platforms = []

Expand All @@ -51,7 +62,10 @@ def run(self):
if self.args.version:
self.odev.run_command("create", "--version", self.args.version, database=self._database)
else:
self.odev.run_command("clone", *passthrough_args, database=self._database)
if self.args.toggle_clone_repo ^ self.odev.config.quickstart.should_clone_repo:
self.odev.run_command("clone", *passthrough_args, database=self._database)
else:
logger.info("Skipping repository cloning")
dumped = self.odev.run_command(
"dump",
*(passthrough_args + (["--filestore"] if self.args.filestore else [])),
Expand Down
19 changes: 19 additions & 0 deletions odev/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ def date(self, value: str | datetime):
self.set("date", value.strftime(DATETIME_FORMAT) if isinstance(value, datetime) else value)


class QuickStartSection(Section):
"""Quickstart configuration."""

@property
def should_clone_repo(self) -> bool:
"""Wherever the repository should be cloned on quickstart"""
value = self.get("should_clone_repo", "True").capitalize()
if value not in ("True", "False"):
raise ValueError(f"'should_clone_repo' config must be one of 'True', 'False', got {value!r}")
return value == "True"

@should_clone_repo.setter
def should_clone_repo(self, value: str | bool):
self.set("should_clone_repo", str(value))


class Config:
"""Odev configuration.
Light wrapper around configparser to write and retrieve configuration values saved on disk.
Expand All @@ -217,6 +233,9 @@ class Config:
repositories: RepositoriesSection
"""Configuration for Odoo repositories."""

quickstart: QuickStartSection
"""Configuration for Odoo quickstart options."""

def __init__(self, name: str = "odev"):
self.name: str = name
"""Name of this config manager, also serves as the name of the file
Expand Down
Loading