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

[ADD] add option rename-to to allow rename addon #64

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

trisdoan
Copy link
Contributor

@trisdoan trisdoan commented Dec 18, 2024

This change

@trisdoan trisdoan marked this pull request as draft December 18, 2024 11:24
@trisdoan trisdoan changed the title [WIP][ADD] add option rename-to to allow rename add [WIP][ADD] add option rename-to to allow rename addon Dec 18, 2024
@trisdoan trisdoan force-pushed the add-rename-to-option branch from dc1f63f to f5d3ad4 Compare December 20, 2024 09:43
@trisdoan trisdoan changed the title [WIP][ADD] add option rename-to to allow rename addon [ADD] add option rename-to to allow rename addon Dec 20, 2024
@trisdoan trisdoan marked this pull request as ready for review December 20, 2024 10:02
@trisdoan trisdoan marked this pull request as draft December 20, 2024 10:15
Comment on lines +99 to 106
or (
self.app.rename_to
and MIG_BRANCH_NAME.format(
branch=self.app.target_version, addon=self.app.rename_to
)
)
or MIG_BRANCH_NAME.format(
branch=self.app.target_version, addon=self.app.addon
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do:

Suggested change
or (
self.app.rename_to
and MIG_BRANCH_NAME.format(
branch=self.app.target_version, addon=self.app.rename_to
)
)
or MIG_BRANCH_NAME.format(
branch=self.app.target_version, addon=self.app.addon
or MIG_BRANCH_NAME.format(
branch=self.app.target_version, addon=(self.app.rename_to or self.app.addon)

addons_tree /= str(self.app.addons_rootdir)
branch_addons = [t.path for t in addons_tree.trees]

if str(self.app.rename_to) in branch_addons:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove the call to str no? Here rename_to is defined, it should be a string.

Suggested change
if str(self.app.rename_to) in branch_addons:
if self.app.rename_to in branch_addons:

@@ -66,6 +66,26 @@
f"\t\t=> {bc.BOLD}" "{new_pr_url}" f"{bc.END}",
]
)
RENAME_TIPS = "\n".join(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the way tips are printed so it's more extendable and maintainable: #65

This RENAME_TIPS can be replaced by a MIG_RENAMED_TIPS with required steps once it's merged.

def _rename_module(self):
if self.app.rename_to:
try:
import git_filter_repo as fr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember a command that was in the OCA documentation in the past to rework history to rename a module, I can't find it anymore...
I tend to reduce the dependencies if possible, especially if a git command can do the job.

Keep this lib for now, I still didn't test your PR :)

And for such feature (renaming a module), we can consider it as required, so such dependency should be in the pyproject.toml (and try/except block can be removed).

@sebalix
Copy link
Collaborator

sebalix commented Dec 20, 2024

Thanks for this work 🙏 I wanted to start working on it yesterday and saw your PR 🎉 I'll test it soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants