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

Fixed package renaming in repmanager #30

Merged
merged 1 commit into from
Oct 19, 2023
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
3 changes: 3 additions & 0 deletions terrarium/dl_repmanager/dl_repmanager/package_meta_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def update_mypy_common(self, to_update: dict[str, str]) -> bool:
section[k] = v
return changes

def update_package_name(self, new_name: str) -> None:
self.toml_writer.set_text_value(section_name=self._SECTION_NAME_MAIN, key="name", value=new_name)


@attr.s
class PackageMetaIOFactory:
Expand Down
18 changes: 5 additions & 13 deletions terrarium/dl_repmanager/dl_repmanager/repository_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re
from typing import (
Callable,
Collection,
Mapping,
Optional,
Sequence,
Expand All @@ -14,6 +13,7 @@

from dl_repmanager.fs_editor import FilesystemEditor
from dl_repmanager.package_index import PackageIndex
from dl_repmanager.package_meta_reader import PackageMetaIOFactory
from dl_repmanager.package_reference import PackageReference
from dl_repmanager.primitives import (
LocaleDomainSpec,
Expand Down Expand Up @@ -340,18 +340,10 @@ def _rename_package_internals(self, old_package_info: PackageInfo, new_package_i
exclude_masks=edit_exclude_masks,
)

# add `-` to the regex
regex, repl = self._make_regex_and_repl_for_sub(
old_str=old_package_info.package_reg_name,
new_str=new_package_info.package_reg_name,
allow_dash=False,
)
self.fs_editor.replace_regex_in_dir(
regex=regex,
repl=repl,
path=new_pkg_dir,
exclude_masks=edit_exclude_masks,
)
# Update reg name
pkg_meta_io_factory = PackageMetaIOFactory(fs_editor=self.fs_editor)
with pkg_meta_io_factory.package_meta_writer(file_path=new_package_info.toml_path) as pkg_meta_writer:
pkg_meta_writer.update_package_name(new_name=new_package_info.package_reg_name)

def change_package_type(self, package_module_name: str, new_package_type: str) -> PackageInfo:
old_package_info = self.package_index.get_package_info_from_module_name(package_module_name)
Expand Down
Loading