diff --git a/oca_port/app.py b/oca_port/app.py index bd08f1d..28531a8 100644 --- a/oca_port/app.py +++ b/oca_port/app.py @@ -76,6 +76,8 @@ class App(Output): dry_run: bool = False output: str = None fetch: bool = False + pre_commit: bool = True + module_migration: bool = True no_cache: bool = False clear_cache: bool = False github_token: str = None diff --git a/oca_port/cli/main.py b/oca_port/cli/main.py index 91e8b01..db6d5a4 100644 --- a/oca_port/cli/main.py +++ b/oca_port/cli/main.py @@ -108,6 +108,16 @@ ), ) @click.option("--fetch", is_flag=True, help="Fetch remote branches from upstream.") +@click.option( + "--pre-commit/--no-pre-commit", + default=True, + help="Run pre-commit hooks after porting.", +) +@click.option( + "--module-migration/--no-module-migration", + default=True, + help="Run odoo-module-migrator after porting.", +) @click.option("--no-cache", is_flag=True, help="Disable user's cache.") @click.option("--clear-cache", is_flag=True, help="Clear the user's cache.") @click.option( @@ -130,6 +140,8 @@ def main( non_interactive: bool, output: str, fetch: bool, + pre_commit: bool, + module_migration: bool, no_cache: bool, clear_cache: bool, dry_run: bool, @@ -165,6 +177,8 @@ def main( non_interactive=non_interactive, output=output, fetch=fetch, + pre_commit=pre_commit, + module_migration=module_migration, no_cache=no_cache, clear_cache=clear_cache, dry_run=dry_run, diff --git a/oca_port/migrate_addon.py b/oca_port/migrate_addon.py index d50cf0f..044de89 100644 --- a/oca_port/migrate_addon.py +++ b/oca_port/migrate_addon.py @@ -156,19 +156,21 @@ def run(self): if self.app.source.addon_path != self.app.target.addon_path: self._move_addon() # Run pre-commit - updated_files = g.run_pre_commit(self.app.repo) - if updated_files: - g.commit( - self.app.repo, - msg=f"[IMP] {self.app.target.addon}: pre-commit auto fixes", - paths=updated_files, - ) + if self.app.pre_commit: + updated_files = g.run_pre_commit(self.app.repo) + if updated_files: + g.commit( + self.app.repo, + msg=f"[IMP] {self.app.target.addon}: pre-commit auto fixes", + paths=updated_files, + ) # Adapt code thanks to odoo-module-migrator (if installed) - try: - metadata.metadata("odoo-module-migrator") - adapted = self._apply_code_pattern() - except metadata.PackageNotFoundError: - pass + if self.app.module_migration: + try: + metadata.metadata("odoo-module-migrator") + adapted = self._apply_code_pattern() + except metadata.PackageNotFoundError: + pass # Check if the addon has commits that update neighboring addons to # make it work properly PortAddonPullRequest(self.app, push_branch=False).run()