-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Refactor main arguments + other improvements #51
Conversation
During a porting session, we could have the need to store some information outside of the repository (to not have dangling files in it). With this new `Session` class, the app is now able to store data like PRs ported or blacklisted during a session (identified by a name generated by dedicated tools) such data could be used at the end of the session, like: - blacklisted PRs/module will be commited all at once in the destination branch (instead of creating a commit in the middle of the session, which doesn't work well) - list of ported PRs will be used to generate the description of the PR opened against the upstream org, or proposed to the user if the PR could not be opened (no remote/org provided by the destination) - ability to remember the blacklisted items of an interrupted porting session, so they can be commited at the end of the session.
6db0963
to
e5a218e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG
oca_port/cli/main.py
Outdated
"""Migrate ADDON from SOURCE to TARGET or list Pull Requests to port | ||
if ADDON already exists on TARGET. | ||
|
||
E.g.: | ||
|
||
$ oca-port OCA/server-tools#14.0 OCA/server-tools#16.0 auditlog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Migrate ADDON from SOURCE to TARGET or list Pull Requests to port | |
if ADDON already exists on TARGET. | |
E.g.: | |
$ oca-port OCA/server-tools#14.0 OCA/server-tools#16.0 auditlog | |
"""Migrate ``addon``` from ``source`` to ``target`` or list PRs. | |
If ``addon`` already exists.... | |
E.g.: | |
$ oca-port OCA/server-tools#14.0 OCA/server-tools#16.0 auditlog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, I used these capitalized terms to align with the command as displayed by --help
thanks to click
:
$ oca-port --help
Usage: oca-port [OPTIONS] SOURCE TARGET ADDON
Migrate ADDON from SOURCE to TARGET or list Pull Requests to port if
ADDON already exists on TARGET.
But we still need to fix the example in this docstring.
With last changes, when re-running the same command twice while having ported some commits in the first run, a WIP status will be displayed: $ oca-port origin/14.0 origin/17.0 server_environment --verbose And running the proposed command to recover the ongoing work could show there is nothing left to port, and therefore propose the user to open the PR (manually here as no destination was set): $ oca-port origin/14.0 oca-port-server_environment-14.0-to-17.0-761c9d server_environment --target-version=17.0 --verbose |
e027378
to
2263d4a
Compare
2263d4a
to
bd0d006
Compare
b95c374
to
d057730
Compare
Introduce 3 concepts: * source: source of the comparison * target: target of the comparison * destination: where to push the work done All of them accept git `[remote/]branch` references, so additional info like repository and organization is retrieved from the remote URL. This is also a preliminary step to support porting from one repo to another (very handy in case of modules moved to different repos). CLI syntax changed to this: $ oca-port origin/14.0 origin/16.0 my_module [--destination camptocamp/dev] A local `dev` branch where commits have already been ported can be resumed this way: $ oca-port origin/14.0 dev my_module --target-version=16.0 [--destination camptocamp/dev] Here we are forced to use an additional parameter `--target-version` as the tool is unable to guess it from `dev` name. A new `--dry-run` option has been added too: $ oca-port origin/14.0 origin/16.0 my_module --dry-run If no remote is defined (detected from destination or target), porting can still be done but the development branch won't be pushed, nor the PR open against the expected repository. However, a brief PR description will be proposed to the user at the end of the session so he'll be able to open the PR by its own if needed. Another improvement is that `PortAddonPullRequest` class doesn't create one branch for each ported PR, resulting in tons of branches created during a porting session. Instead, the destination branch is used (if provided) or one will be created automatically (name based on list of PRs to port, so re-running the command twice generates the same branch name in most use cases). Of course, setting your own destination branch is recommended to preserve the full control of your porting session. Also, the blacklisting of PRs/modules have been refactored to not create files to commit in the middle of a porting session. Instead, if a PR is set as blacklisted, this information will be stored in the user's session and commited at the end of the porting session. If for any reason the porting session is interrupted, such data are not lost when re-running the command again. Co-authored-by: Simone Orsi <simahawk@gmail.com> Co-authored-by: Sébastien Alix <sebastien.alix@camptocamp.com>
When using oca-port as a Python package to collect migration data where repositories are cloned on a filesystem with very low IO perf, the process could take a lot of time to finish (every underlying git operations to retrieve for instance updated file paths of a commit are very costly). Such process could be killed before it actually finishes (and write the data in cache). By setting the OCA_PORT_AGRESSIVE_CACHE_WRITE environment variable, we force oca-port to update the cache very often, generating more IO during the first analysis of a module, but making the next process execution much faster. As this is an advanced option, it is exposed through an environment variable to not clutter the usual parameters.
d057730
to
1c873cc
Compare
Context
This is a rework of #33 , and bring breaking changes, both for CLI tool and API if used as a Python package.
Description
Introduce 3 concepts:
All of them accept git
[remote/]branch
references, so additional info like repository and organization is retrieved from the remote URL.This is also a preliminary step to support porting from one repo to another (very handy in case of modules moved to different repos).
CLI syntax changed to this:
A local
dev
branch where commits have already been ported can be resumed this way:Here we are forced to use an additional parameter
--target-version
as the tool is unable to guess it fromdev
name.A new
--dry-run
option has been added too:If no remote is defined (detected from destination or target), porting can still be done but the development branch won't be pushed, nor the PR open against the expected repository. However, a brief PR description will be proposed to the user at the end of the session so he'll be able to open the PR by its own if needed:
Remote is not mandatory for
source
,target
anddestination
, so we can work fully with local branches:Another improvement is that
PortAddonPullRequest
class doesn't create one branch for each ported PR, resulting in tons of branches created during a porting session. Instead, the destination branch is used (if provided) or one will be created automatically (name based on list of PRs to port, so re-running the command twice generates the same branch name inmost use cases). Of course, setting your own destination branch is recommended to preserve the full control of your porting session.
Also, the blacklisting of PRs/modules have been refactored to not create files to commit in the middle of a porting session. Instead, if a PR is set as blacklisted, this information will be stored in the user's session and commited at the end of the porting session. If for any reason the porting session is interrupted, such data are not lost when re-running the command again, and the user will be prompted if he still wants to blacklist such PR:
How to install and test this PR
Examples
Run a comparison for
stock_restrict_lot
in verbose mode first in--dry-run
with--fetch
to ensure we get the last changes locally:This had the effect to put some data in the user's cache, so further similar commands will be faster to run.
Re-run the same command without
--dry-run
nor--fetch
, but with--destination
(here a local branch) to not let the tool generates the destination branch automatically:Up to the user to resolve the conflicts manually (then
git add [...] && git am --continue
orgit am --skip
) before continuing the porting session. Answering no will perform agit am --abort
before trying to port the next commit of the PR (if any), or propose to port the next PR.In case the porting session is interrupted, we can resume it by changing restarting the comparison using our destination branch also as the target (with the help of
--target-version
so the tool knows which version we are talking about), so already ported commits won't be listed anymore:Running the same command once everything is ported will produce this result:
TODO: