Skip to content

Commit

Permalink
Merge pull request #69 from plesk/avoid-duplicates-on-replacement
Browse files Browse the repository at this point in the history
Prevent duplicate prefixes for repository ID and name when adopting an RPM repository
  • Loading branch information
SandakovMM authored Sep 2, 2024
2 parents d7a5bc7 + a589ddd commit ea6cbfb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pleskdistup/common/src/leapp_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def _do_replacement(

def _do_id_replacement(id: typing.Optional[str]) -> typing.Optional[str]:
return _do_replacement(id, [
lambda to_change: "alma-" + to_change,
lambda to_change: "alma-" + to_change if not to_change.startswith("alma-") else to_change,
])


def _do_name_replacement(name: typing.Optional[str]) -> typing.Optional[str]:
return _do_replacement(name, [
lambda to_change: "Alma " + to_change,
lambda to_change: "Alma " + to_change if not to_change.startswith("Alma ") else to_change,
lambda to_change: to_change.replace("Enterprise Linux 7", "Enterprise Linux 8"),
lambda to_change: to_change.replace("EPEL-7", "EPEL-8"),
lambda to_change: to_change.replace("$releasever", "8"),
Expand Down
20 changes: 20 additions & 0 deletions pleskdistup/common/tests/leapp_configs_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,26 @@ def test_rackspace_mapping(self):
self._perform_test({"mariadb.repo": mariadb_like_repos},
expected_mariadb_repos, expected_mariadb_mapping)

def test_avoid_duplicated_prefixes(self):
prefixed_repo = """[alma-repo1]
name=Alma repo1
baseurl=http://repo1/rpm-CentOS-7
enabled=1
gpgcheck=0
"""

expected_leapp_repos = """[alma-repo1]
name=Alma repo1
baseurl=http://repo1/rpm-RedHat-el8
enabled=1
gpgcheck=0
"""

expected_leapp_mapping = """alma-repo1,alma-repo1,alma-repo1,all,all,x86_64,rpm,ga,ga
"""

self._perform_test({"prefixed.repo": prefixed_repo}, expected_leapp_repos, expected_leapp_mapping)


class SetPackageRepositoryTests(unittest.TestCase):
INITIAL_JSON = {
Expand Down

0 comments on commit ea6cbfb

Please sign in to comment.