Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md + fix port of modules located in a subfolder #58

Merged
merged 2 commits into from
Nov 20, 2024
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
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,47 @@ not fully ported grouped by Pull Request and propose to port them.

Syntax:

$ oca-port <source> <target> <module> [options]
$ oca-port <source> <target> <module_path> [options]
$ oca-port --help

To check if an addon could be migrated or to get eligible commits to port:

$ export GITHUB_TOKEN=<token>
$ cd <path/to/OCA/cloned_repository>
$ oca-port origin/14.0 origin/16.0 <module> --verbose --dry-run
$ oca-port origin/16.0 origin/18.0 <module_path> --verbose --dry-run

To effectively migrate the addon or port its commits, remove the `--dry-run` option
so the tool will create a working local branch automatically (called destination)
from the `<target>` branch:

$ oca-port origin/14.0 origin/16.0 <module>
$ oca-port origin/16.0 origin/18.0 <module_path>

You can control the destination with the `--destination` option:

$ oca-port origin/14.0 origin/16.0 <module> --destination camptocamp/16.0-port-things
$ oca-port origin/16.0 origin/18.0 <module_path> --destination camptocamp/18.0-port-things

The module can be located in a subfolder, and the tool can be used in any kind of repository, e.g:

$ oca-port origin/main origin/18.0-mig --source-version=16.0 --target-version=18.0 --upstream-org=camptocamp ./odoo/local-src/MY_MODULE --verbose --destination sebalix/18.0-mig-MY_MODULE

- parameters `--source-version` and `--target-version` are mandatory as soon as
the `source`/`target` parameters cannot be recognized as Odoo versions (here
`origin/main` is hosting a `16.0` version)
- `--upstream-org` defaults to `OCA`, here we set it to `camptocamp` for GitHub API requests

You can also directly blacklist a bunch of PRs on a given branch thanks to the
`oca-port-pr` tool:

$ oca-port-pr blacklist OCA/wms#250,OCA/wms#251 15.0 shopfloor
$ oca-port-pr blacklist OCA/wms#250,OCA/wms#251 16.0 shopfloor

You could give a more detailed reason of this blacklist with `--reason` parameter:

$ oca-port-pr blacklist OCA/wms#250,OCA/wms#251 15.0 shopfloor --reason "Refactored in 15.0, not needed anymore"
$ oca-port-pr blacklist OCA/wms#250,OCA/wms#251 16.0 shopfloor --reason "Refactored in 16.0, not needed anymore"

And if the module has been moved to another repository, you can specify its remote as well:

$ git remote add new_repo git@github.com:OCA/new-repo.git
$ oca-port-pr blacklist OCA/wms#250,OCA/wms#251 15.0 shopfloor --remote new_repo
$ oca-port-pr blacklist OCA/wms#250,OCA/wms#251 16.0 shopfloor --remote new_repo

Migration of addon
------------------
Expand Down Expand Up @@ -101,7 +110,7 @@ You can also use `oca-port` as a Python package:
>>> app = oca_port.App(
... source="origin/14.0",
... target="origin/16.0",
... addon="stock_move_auto_assign",
... addon_path="stock_move_auto_assign",
... upstream_org": "OCA",
... repo_path": "/home/odoo/OCA/stock-logistics-warehouse",
... output": "json",
Expand Down
10 changes: 9 additions & 1 deletion oca_port/utils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ def paths(self):
"""
if self._paths:
return self._paths
self._paths = {CommitPath(self.addons_path, f) for f in self.files}
self._paths = set()
for f in self.files:
# Could raise "ValueError: 'f' is not in the subpath of 'addons_path'"
# in such case we ignore these files, and keep ones in 'addons_path'
try:
commit_path = CommitPath(self.addons_path, f)
except ValueError:
continue
self._paths.add(commit_path)
return self._paths

def _get_files(self):
Expand Down
Loading