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
2 changes: 2 additions & 0 deletions oca_port/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions oca_port/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 14 additions & 12 deletions oca_port/migrate_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down